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!

Why can't I upload an empty file?

Status
Not open for further replies.

countdrak

Programmer
Jun 20, 2003
358
US
Is this a cffile issue? I can't upload an empty .txt file using cffile.

This is the error I get.

No data was received in the uploaded file "log.txt".
<br>Saving empty (zero-length) files is prohibited. <br>Verify that you specified the correct file.


Whats the workd around? Is there a way to check if there is no data in the file and still be able to upload an empty file?
 
why upload an empty file? There isn't much sence in that.
Use cffile to create a file one instead.

<cffile action="Write"
file="fully/qualified/path/empty.txt"
output="">


If output="" doesn't work try output=" "


A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
But why would you need an empty file on the server anyway? If it's for something you'll use in the future just do a check to see if the file exists, if not make it with the data you need to insert. if it does, read or append to it.

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Thanks. :) I am not trying to upload an empty file, but say one of the users might try doing that and then my system breaks! Was trying to find a way where I can check-- If someone tries uploading a file to the server and the file is empty, then the code doesnt do anything or sends back a message-- "File upload failed
 
Cfcatch and cftry should do the trick for you.

<cftry>
<cffile action = "upload">
<cfcatch>
<cfoutput>
File Upload Failed
</cfoutput>
</cfcatch>
</cftry>

A common mistake that people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
-Douglas Adams (1952-2001)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top