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
LVL 1
hefterrAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
gdemariaConnect With a Mentor Commented:
>  I've never used this before.  So what do I do next?

You forgot to say what you're trying to do...

Is the code not finished and you're trying to complete it or is there a bug or ?


Check the <FORM action to see what file is processing the file upload.  That's where a variable called "form.picField"  will be used to upload the file (using CFFILE action="uload") and then perhaps save it to the database ...

0
 
_agx_Commented:
><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(...)"
0
 
hefterrAuthor Commented:
@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  
0
 
_agx_Connect With a Mentor Commented:
> I'm not concerned about the front end design.  I just wanted to know
> what code would get it's hand on the file.

I understand, but that code will give you the answer. It has to be sending the file somewhere, like to a .cfm script on your server.  That code is probably using cffile upload like gdemaria said. But like I said, reviewing the function code should answer your questions.

But if you just want to create your own upload form use gdemaria's suggestion.  Just be sure to use
enctype="multipart/form-data". It's required for <form>'s with file inputs.


0
 
hefterrAuthor Commented:
@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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.