ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 5th, 2005, 01:21 PM
TanzMatias TanzMatias is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 10 TanzMatias User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 53 m 3 sec
Reputation Power: 0
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!!

Reply With Quote
  #2  
Old May 5th, 2005, 01:44 PM
CfFreelancer CfFreelancer is offline
CF Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Long Island, NY
Posts: 34 CfFreelancer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 29 m 50 sec
Reputation Power: 5
use FileExists to check if the file already exists

<cfif FileExists(......)>
option to rename...
<cfelse>
code to upload...
</ciff>

Reply With Quote
  #3  
Old May 5th, 2005, 01:53 PM
TanzMatias TanzMatias is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 10 TanzMatias User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 53 m 3 sec
Reputation Power: 0
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?

Reply With Quote
  #4  
Old May 5th, 2005, 01:57 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,661 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 14 h 23 m 22 sec
Reputation Power: 53
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

Reply With Quote
  #5  
Old May 5th, 2005, 01:57 PM
CfFreelancer CfFreelancer is offline
CF Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Long Island, NY
Posts: 34 CfFreelancer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 29 m 50 sec
Reputation Power: 5
what about uploading to a TEMP directory and then allow the user to rename..then you can just MOVE the file with CFFILE

Reply With Quote
  #6  
Old May 5th, 2005, 02:07 PM
TanzMatias TanzMatias is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 10 TanzMatias User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 53 m 3 sec
Reputation Power: 0
Quote:
Originally Posted by CfFreelancer
what about uploading to a TEMP directory and then allow the user to rename..then you can just MOVE the file with CFFILE


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!

Reply With Quote
  #7  
Old May 5th, 2005, 02:16 PM
CfFreelancer CfFreelancer is offline
CF Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Long Island, NY
Posts: 34 CfFreelancer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 29 m 50 sec
Reputation Power: 5
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>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > ERROR: The form field "theFile" did not contain a file.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway