Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Uploaded files not opening when clicked on

Status
Not open for further replies.

WebGodiva

Technical User
Jun 21, 2000
263
US
I have created a library page on one of my sites.&nbsp;&nbsp;Everything tests fine on my machine but when I uploaded it to the server, none of the files that are uploaded via the browser are accessible.&nbsp;&nbsp;When you click on their hyperlink you either get the 404 or an error that your systems settings need to be changed.<br><br>the code for this page (the open file page) is:<br><br>&lt;cfif not isdefined(&quot;session.authenticated&quot;)&gt;<br>&nbsp;&nbsp;&lt;cfoutput&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;You are not authenticated, or your session has timed out<br>&nbsp;&nbsp;&lt;/cfoutput&gt;<br>&nbsp;&nbsp;&lt;cfabort&gt;<br>&lt;/cfif&gt;<br>&lt;!--- security check ---&gt;<br>&lt;CFIF Find( '..', URL.ServerFile )<br> or Find( '\', URL.ServerFile )<br> &gt;<br> Error: You are not allowed to access this file<br> &lt;CFABORT&gt;<br>&lt;/CFIF&gt;<br><br><br><br>&lt;!--- parameters ---&gt;<br>&lt;CFSET LibraryDirectory = &quot;d:\webserver\Site-Blauvelt.com\ FilePath = &quot;#LibraryDirectory#\#URL.ServerFile#&quot;&gt;<br><br><br>&lt;!--- extract the file extension ---&gt;<br>&lt;CFSET SeparatorPos = Find( '.', Reverse(URL.ServerFile) )&gt;<br>&lt;CFIF SeparatorPos is 0&gt; &lt;!--- separator not found ---&gt;<br> &lt;CFSET FileExt = ''&gt;<br>&lt;CFELSE&gt;<br> &lt;CFSET FileExt = Right( URL.ServerFile, SeparatorPos - 1 )&gt;<br>&lt;/CFIF&gt;<br><br><br>&lt;!--- find the proper MIME type ---&gt;<br>&lt;CFIF FileExt is ''&gt; &lt;CFSET FileType = &quot;unknown&quot;&gt;<br>&lt;CFELSEIF FileExt is 'pdf'&gt; &lt;CFSET FileType = &quot;application/pdf&quot;&gt;<br>&lt;CFELSEIF FileExt is 'aif'&gt; &lt;CFSET FileType = &quot;audio/aiff&quot;&gt;<br>&lt;CFELSEIF FileExt is 'aiff'&gt; &lt;CFSET FileType = &quot;audio/aiff&quot;&gt;<br>&lt;CFELSEIF FileExt is 'art'&gt; &lt;CFSET FileType = &quot;image/x-jg&quot;&gt;<br>&lt;CFELSEIF FileExt is 'cil'&gt; &lt;CFSET FileType = &quot;application/vnd.ms-artgalry&quot;&gt;<br>&lt;CFELSEIF FileExt is 'gif'&gt; &lt;CFSET FileType = &quot;image/gif&quot;&gt;<br>&lt;CFELSEIF FileExt is 'htm'&gt; &lt;CFSET FileType = &quot;text/html&quot;&gt;<br>&lt;CFELSEIF FileExt is 'html'&gt; &lt;CFSET FileType = &quot;text/html&quot;&gt;<br>&lt;CFELSEIF FileExt is 'wk4'&gt; &lt;CFSET FileType = &quot;application/wk4&quot;&gt;<br><br>&lt;CFELSE&gt; &lt;CFSET FileType = &quot;unknown&quot;&gt;<br>&lt;/CFIF&gt;<br><br><br>&lt;!--- return requested file ---&gt;<br>&lt;CFCONTENT TYPE=&quot;#FileType#&quot; <br> FILE=&quot;#FilePath#&quot;<br>&gt;<br><br>You can access the page by going to: <A HREF=" TARGET="_new"> user name is Penndot and the password is Guest001.<br><br>I am new to CF and am working hard to learn it and get this site up and running at the same time. Any suggestions would be appreciated.<br>
 
I took a look and the files seem to be loading okay, but the urls looked kind of strange...&nbsp;&nbsp;<br><br><A HREF=" TARGET="_new"> shouldn't need the ?ServerFile=Penndot.gif portion of that url.&nbsp;&nbsp;If you want to do a redirect type of thing, you could use something like:<br><br><A HREF=" TARGET="_new"> the redirect page would have:<br><br>&lt;cflocation url=&quot;Penndot.gif&quot; addtoken=&quot;no&quot;&gt;<br><br>You could do other processing before the CFLOCATION tag to count clickthroughs, set mime types, or whatever....
 
Darkman,<br><br>Thank you for your help.&nbsp;&nbsp;I appreciate you taking the time to look at it.&nbsp;&nbsp;I will try the redirect portion for the site.<br><br>Again, Thanks BUNCHES!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top