Showing results for 
Show  only  | Search instead for 
Did you mean: 
New Member

How to make file URLs open in browser instead of downloading?

I'm using direct file URLs to link to files in Canvas (along the lines of ), but the browser then automatically tries to download the file instead of just opening it (most of my files are PDFs) or previewing it.  Is there a way to generate a link which will open / preview instead of downloading?

Tags (3)
12 Replies
Community Contributor

Hi, Janet, @Janet Chen 

If linked to your file folder, the file should have a preview icon "the magnifier lens" right after the link, have your students click on that icon, it opens preview mode without downloading. 

Of course, you can embed the file within an iframe tag as well, but the code needs some tweaks. The best way is to host it in google drive and embed the file in the page, it displays the pdf in a window and still downloadable. 

Community Contributor

To elaborate on this post,

I like the idea of using Google Drive to embed the file.

I found a link with instructions on how to do it: Google Sites - Embed PDF from Google Drive - Google Sites Experts Designs Development Intranets Webs... 

I think the only difference from these instructions is that now in order to open the PDF in a "pop-out" you open the PDF in Drive, and in the overflow menu (...) select "Open in new window" and then follow the steps from the link to get the embed code for your page/assignment.

Sorry, I'm a bit confused.  Maybe I should clarify; I have a non-Canvas webpage, and on that I want to link to a Canvas file using its filename.  Since the page is not in Canvas, it doesn't get the typical preview icon.

janetchen‌, files that are stored in Canvas are not publicly visible, so if you create a link to that file in a "non-Canvas webpage," the only people who will be able to see it will be (a) students who are authenticated into Canvas and enrolled in the specific course to which the file has been uploaded to course files, or (b) you alone, if you have uploaded it to your My Files space in your Canvas account. Are you sure you want to create a link in an external web page to a file stored in Canvas? 

The Community might be able to work with you on solutions if you could describe the use case, provide some design and navigation details, and accompany that with screenshots.

Yes, that's exactly what I want; the separate website is intended only for students in the course and will include links to files that should only be accessible by students who are actually enrolled in the course.  (The reason the website will be outside of Canvas is because of how it ties in with other scripting.)  But I'd prefer to link to files using the method described by Mike Hower here, because of the issue described by James Khazar here.  

Community Champion

I am commenting here just to make sure I follow this conversation. I was under the impression that you cannot really access Canvas Files in the usual way you might want to, just using a URL (which is one of many reasons why I actually don't use Canvas for any content hosting). If there is a way to do that, though, I would like to learn how! 

Laura, I use exactly the method described by in this discussion.

Basically, it works like this: suppose your main Canvas site is named something like  If you've organized your files in a directory structure and have a file named file.pdf in a folder named myfolder, you can link to it as

(The minor downside that I'm trying to address is that it appears that, when someone clicks this link, they will automatically download the file rather than having the browser open it or being given a preview.)

Exactly! Same also for a jpg. So whatever the Canvas server is telling the browser is not the usual "here's the file!" message.

Community Coach
Community Coach

Hello janetchen...

I noticed that there hasn't been any new activity in this discussion topic sine August 17th, and so I wanted to check in with you.  Although I do not have any solutions for you myself, I do agree with stefaniesanders‌ that using a non-Canvas website to add links to files on that site back to the "Files" area of your Canvas course will not work...because those files are essentially behind a username/password.  Have you found any alternatives in the mean time that might work for you?  Or, are you still looking for some suggestions on how this can be accomplished?  Or, if you feel that one of the above responses has helped to answer your question, please go ahead and mark it as "Correct".  For now, since we haven't had any new activity in this thread for quite a while, I'm going to mark your question as "Assumed Answered", but that won't stop you or others from posting additional questions/comments below.  I hope that's alright with you, Janet.  Looking forward to hearing back from you soon!