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

CFFILE upload prevention if not file exisits...

Status
Not open for further replies.

gambhir

Programmer
Oct 17, 2000
15
0
0
US


I have several file uploads from a form. While a user may upload some files, they are not required to fill in all of them. On the processing page for the file uploads I want to prevent a file upload if no file was specified on the first page. I tried implmenting a <CFIF &quot;value&quot; IS NOT &quot;&quot;> around my CFFILE upload on the processing page, however that did not work. Anyone have any ideas?


Page 1:

<td align=&quot;right&quot;><b><font face=&quot;Tahoma, Arial&quot; size=&quot;2&quot;>Attach photograph of Driver<br>
</font><font face=&quot;Tahoma, Arial&quot; size=&quot;1&quot;>No more than
12 months old</font><font face=&quot;Tahoma, Arial&quot; size=&quot;2&quot;><br>
</font><font face=&quot;Tahoma, Arial&quot; size=&quot;1&quot;>(click on 'Browse' to locate Photograph file)</font></b></td>
<td></td>



On the page that process the file upload I need to prvent a file upload if the user decides not to upload a file:

<CFIF &quot;licensephoto&quot; IS NOT &quot;&quot;>
<CFFILE ACTION=&quot;Upload&quot;
FILEFIELD=&quot;licensephoto&quot;
DESTINATION=&quot;c:\web\upload\&quot;
ACCEPT=&quot;image/jpg, image/pjpeg,image/gif,image/bmp, image/tiff&quot;
NAMECONFLICT=&quot;OVERWRITE&quot;>
</cfif>


This did not work when I did not attach a file. I got an error. I got the following error message:
Error processing CFFILE

No data was received in the uploaded file '\.' Saving empty (zero-length) files is prohibitted. Please make sure you specified the correct file

This leads me to the belief that the CFIF wrap around the file upload is not working. I need to prevent a file upload transaction if no file was specfied

Thanks ahead of time

 
I wasn't sure how files to be uploaded were specified, since i can't see <INPUT TYPE=&quot;FILE&quot;....>. But I'm assuming this is what your users will be using to upload.

(1) Make sure that you specified the attributes NAME=&quot;licensephoto&quot; and VALUE=&quot;&quot; in the INPUT tag.

(2) If this doesn't work, try adding variable existence check in your second page, before checking for null values.

eg.
<CFIF ISDEFINED(&quot;FORM.licensephoto&quot;)>
<CFIF Trim(Form.licensephoto) IS NOT &quot;&quot;>
......... (code that processes the upload)
</CFIF>
</CFIF>

(3) Optional - You can do the validation, whether the file was specified, before loading the second page using JavaScript. Not sure if you wanted this, so just post back to this forum or at the javascript forum if you need help on this.
 
This is just a shot in the dark, but the error message syas: No data was received in the uploaded file '\.' . Why not modify you <cfif> tag to make sure the filename is not just '\'. If it is, no upload, if it isn't...


bankholdup
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top