|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
ERROR: The form field "theFile" did not contain a file.
I'm getting this error when a user uploads a file. (I do have ENCTYPE="multipart/form-data" in the form definition.) If the user tries to upload a file that already exists, I would like him to be able to choose whether or not the file gets overwritten. The first page displayed to the user has the input field:
<INPUT TYPE="FILE" NAME="theFile"> When the user hits submit, CF discovers that the file already exists. What I would like to do is display the second page to the user with the file attempting to upload asking if he wishes to overwrite the alredy existing file. What I'm running into, is that I can't seem to upload a file with using TYPE="FILE" input field. On this second page I CANNOT use a TYPE="HIDDEN" VALUE="#theFile#" field, or assign the already chosen file in TYPE="FILE" VALUE="#theFile#" b/c you cannot use the VALUE attribute. Any ideas or suggestions?? Thanks!! |
|
#2
|
|||
|
|||
|
use FileExists to check if the file already exists
<cfif FileExists(......)> option to rename... <cfelse> code to upload... </ciff> |
|
#3
|
|||
|
|||
|
I've been able to find if the file exists are not, but where I'm stuck is what to do at the "option to rename" clause. After the user chooses the file & hits submit is when CF discovers the file already exists (which I'm successful at doing). Without having the user have to choose the file again (with some friendly message), how can I (after displaying the file name & asking him if he wishes to overwrite) upload the file if there is no <INPUT TYPE="FILE"...> input field?
|
|
#4
|
|||
|
|||
|
You must use cffile action="upload" on the action page to do anything on the server with the file, including checking to see if the file already exists.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#5
|
|||
|
|||
|
what about uploading to a TEMP directory and then allow the user to rename..then you can just MOVE the file with CFFILE
|
|
#6
|
|||
|
|||
|
Quote:
CfFreelancer -- That sounds like it would work, but a pretty round about way. This must be a workflow that is not out of the ordinary... User chooses to upload a file--> file exists--> give option to upload & overwrite --> upload & overwrite. I was also having the same problem with a verification page after the user chooses to upload a file. A sort of "Are you sure you wish to upload this file" message before uploading the file. I couldn’t get it to work either, so I just abandoned it. But... to do it the same way as you described above, I would upload the file to a TEMP directory once the user submits the file on the first page. On the verification page, after the user decides it is indeed the right file and hits submit, the file is moved to the actual directory. If the user chooses not to upload the file (maybe because he chose the wrong file) the file is deleted from the TEMP directory. Thanks for the suggestion! |
|
#7
|
|||
|
|||
|
For the "Are you sure...?" you can use a javascript confirm
Something like... <script language="JavaScript"> function areyousure(x) { question = confirm("Are you sure you want to upload"+x+ " ?") if (question !="0"){ document.forms[0].submit(); } } </script> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > ERROR: The form field "theFile" did not contain a file. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|