Link to home
Start Free TrialLog in
Avatar of hefterr
hefterrFlag for United States of America

asked on

Image File Upload to ColdFusion Server

Hi,
I have a page that will upload images using something similar to this :

<cfif isDefined("fileUpload")>
  <cffile action="upload"
     fileField="fileUpload"
     destination="C:\docs">
     <p>Thankyou, your file has been uploaded.</p>
</cfif>
<form enctype="multipart/form-data" method="post">
<input type="file" name="fileUpload" /><br />
<input type=text name="marketComment">
<input type="submit" value="Upload File" />
</form>

Open in new window


I do have a few other associated fields that are validated in this process. In this example I used a required field "marketComment".

If I need to redisplay the page because of an error (say the text field contained invalid characters),  I can redisplay the contents of the text field, but I don't seem to be able to redisplay the "chosen file" to upload.  The form field (form.fileUpload) only contains the location of the uploaded file on the CF server.

Is there a way to do this?  Or is this a Web security issue?

Thanks,
hefterr
Avatar of RickEpnet
RickEpnet
Flag of United States of America image

Validate you form before it is submitted. I would use cfform instead of just a plain form.

Here is an example of a validation cfform.

<cfform action="unitedit.cfm" method="post" name="editatm" preloader="no">
<cfinput type="text" name="Account" message="Account Number is Required" required="yes" style="width: 100px;"maxlength="50">
<cfinput type="text" name="UNIT_ID" message="Unit ID is Required" required="yes" style="width: 100px;" maxlength="50">  
</cfform>
Avatar of hefterr

ASKER

Hi RickEpnet,
I was still wondering about my original question.  My boss doesn't like the popup edit messages.  We format our own.

hefterr
SOLUTION
Avatar of RickEpnet
RickEpnet
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hefterr

ASKER

Thanks for the alternative ideas.