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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cffile

Status
Not open for further replies.

GUJUm0deL

Programmer
Jan 16, 2001
3,676
US
Hey, this was working just perfectly, then all of a sudden it stopped, any ideas?


<cfif Uploading is &quot;&quot; OR Uploading NEQ accept>
<cflocation addtoken=&quot;no&quot; url=&quot;Upload1.cfm?Note=Sorry, only image files are accepted!&quot;>
<cfelse>
<cffile action=&quot;upload&quot; filefield=&quot;Uploading&quot; destination=&quot;...&quot; nameconflict=&quot;makeunique&quot; accept=&quot;image/*&quot;>
<cfquery>...</cfquery>
</cfif>
...
</cfif>


Basically, the portion in red checks if the upload file is blank or is NEQ the accept parameter in <cffile>

Like I said, it was working just fine, then when I uploaded the file after adding the datecheck, it stopped working.

Any ideas why? Thanks.


____________________________________
Just Imagine.
 
Correct me if I'm wrong, but on your test server it works and not on your live server??

If this is the case it's somewhere in your CFFILE tag.
what kind of error do you get???
 
CFdutch, the error I get is Sorry, only image files are accepted., as depicted in the &quot;Note&quot; var. Its the same error as if the user tried to upload a blank file.

This worked on a live server also, but then when I did a date chhange, it stopped working. I took out the date change and brought the code back to the way it was before, and still no luck. Just want to know if the <cfif> syntax is right. Maybe it was a fluke that it worked.

Thanks.


____________________________________
Just Imagine.
 
Maybe this can help. It has extra code but you might need it to see where I going with this.

========================================================

<cfif not #form.attachment# is &quot;&quot;>
<!---Can also use CFFILE ACCEPT=&quot;&quot; to filter images. Goes before action--->
<cffile action=&quot;upload&quot;
filefield=&quot;attachment&quot;
destination=&quot;D:\webroot\Dev\attachment&quot;
nameconflict=&quot;makeunique&quot;>

<cfset jpg1 = '#file.ServerFile#'>
<cfset filesize = '#file.FILESIZE#'>
<cfset jpg2 = '#FILE.ClientFile#'>
<cfset mypath = &quot;D:\webroot\Dev\attachment\&quot;&#jpg1#>
<cfset filename = #urlencodedformat(File.Serverfile)#>
<cfoutput>
The jpgument attached is named: #jpg2# <br>
The maximum file size limit is: 151251 (#DecimalFormat(151251/1000)# k)<br>
The file size you are trying to upload is: #filesize# (#DecimalFormat(filesize/1000+.009)#
k)<br>
</cfoutput>

<cfif #filesize# gt 151251>
Your file is too large! (Max size is 150k)
<cffile
action=&quot;delete&quot;
file=&quot;#mypath#&quot;>
<a href=&quot;Javascript: history.back()&quot;>Go Back</a>
<cfabort>
<cfelse>
<!---Another way to check for a jpg extension--->
<cfset newstring = &quot;&quot;>
<cfloop from=&quot;1&quot; to=&quot;3&quot; index=&quot;i&quot;>
<cfset chr = Mid(#jpg1#,(#Len(jpg1)#+1-i),1)>
<cfset newstring = chr&newstring>
</cfloop>
The extension on this file is: <cfoutput>#newstring#</cfoutput><br>
<!---CFFILE.ClientFileExt also Checks for a jpg extension--->
<cfif #newstring# neq &quot;jpg&quot; OR CFFILE.ClientFileExt neq &quot;jpg&quot; AND #filesize# lt 51251>
<cffile
action=&quot;delete&quot;
file=&quot;#mypath#&quot;>
This is not the correct file format, please <a href=&quot;Javascript: history.back()&quot;>Go Back</a> and upload again <br>

<cfabort>
<cfelse>
</cfif>
</cfif></cfif>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top