Solved

Upload a File to the Server - Coldfusion

Posted on 2011-09-23
5
300 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:hefterr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 250 total points
ID: 36587941
>  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
 
LVL 52

Expert Comment

by:_agx_
ID: 36588030
><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
 
LVL 1

Author Comment

by:hefterr
ID: 36588168
@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
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 250 total points
ID: 36588269
> 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
 
LVL 1

Author Closing Comment

by:hefterr
ID: 36588394
@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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dynamic Table mySQL stored procedure 5 64
CSV export single column not inserting comma's in file 11 67
Jquery Calculation 3 43
Google Chrome: Debugging AJAX call 6 39
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question