I try to load a pdf file into an iframe using JavaScript in a magento page: My pdf files are stored in /media/subdirectory.

I declared a .htaccess for my subdirectory in order to allow access, and When i go to the url www.mysite.com/media/subdirectory/myfile.pdf, the file is displayed in my browser.

But, when I define this url as my iframe src, my iframe loads the 404 page... (I checked the src url by copy/paste the src url into the browser, and the url is good)

Any idea why?

  • Provide the details of the browser on which your are trying. Some browsers wont support iframes. – PHP Bugs Apr 25 '15 at 9:29
  • same results both on Firefox and Safari – Alexglvr Apr 25 '15 at 9:53

Magento closed access only to folder downloadable in media folder. In your case everything should work properly. Try to check file/folder permissions.

  • directory is 755 and file is 655. What is strange is that i can access the file if I put the iframe src url directly in the browser. – Alexglvr Apr 25 '15 at 9:57
  • Show us your iframe code – zhartaunik Apr 25 '15 at 11:28
  • <iframe id="deliverypdf-frame" style="display: none;" src="www.xxxxx.fr/media/custom_options/deliverytmp/delivery_100000311_100000057.pdf"></iframe> – Alexglvr Apr 25 '15 at 14:46

Looking into it a little, there seems to be inconsistencies and issues loading a pdf in an iframe from browser to browser, but possibly some work arounds may work for you.

Take a look at this answer from a similiar question, it may help you out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.