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

asked on

Upload a File to the Server - Coldfusion

Hi,
I have an application (similar to this one) where I need to have a "search" link/image that will allow the user to browse their hard drive for an image file and select it.  Then an "upload" will pass the image file to the ColdFusion server.  This is very similar to the  "image" feature used in Expert's Exchange.   The image will then be used on subsequent pages for display.

I have a feeling some JavaScript and/or JQuery may also be needed?  The front end quy  (on vacation) has some  JQuery code:
 
<div class="addPub_category upload_img-bottom">
			<div class="category_title3"><h1>Upload Multiple Organizations</h1></div>

				<input type="file" id="picField" onchange="preview(this)"></input>
			
				</div><!--ends category-->

Open in new window


This opens the dialog box and attaches a small icon when selected.  Not sure how this works.

How does this get to the server?  I guess it's passed as a form field as Type=File?   I've never used this before.  So what do I do next?

Thanks in advance,
hefterr
ASKER CERTIFIED SOLUTION
Avatar of gdemaria
gdemaria
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
><input type="file" id="picField" onchange="preview(this)"></input>

..  And are you specifically trying to use his code or trying to write something new? If you're trying to use his code, look for the javascript method "preview(...)"
Avatar of hefterr

ASKER

@gdemaria:
>>You forgot to say what you're trying to do.
..

I haven't written the code yet (just going over the requirements).  I will need to store the image file in a directory and the name of the file on in a table so I can redisplay the image in an inquiry/search function.

@_agx_:
And are you specifically trying to use his code or trying to write something new? If you're trying to use his code, look for the JavaScript method "preview(...)"

I can't find the function.  I believe it's a JQuery function which I really don't know anything about.  I'm not concerned about the front end design.  I just wanted to know what code would get it's hand on the file.

Is it using CFFILE action="upload"?  (I never used that option before).  I think I have to give a name to the <INPUT> (name = "upimage") and refer to form.upimage?  gdemaria used the ID in her example.

I think you guys answered my questions:
-  It's a basic form field.
-  Use CFFILE to store it.

Thanks,
hefterr  
SOLUTION
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

@agx:   It has to be sending the file somewhere, like to a .cfm script on your server.

Yes, I'm takinf the basic HTML/Jquery and adding the Coldfusion to process the form (as a *cfm).

Thanks to both for your help!

hefterr