• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Uploading images : how

Guest
Nov 06, 2006 Nov 06, 2006

Copy link to clipboard

Copied

Hi, I';m trying to put together a form that lets me upload a file (an image specifically). I'm using the fusebox framework but that shouldt make a difference. I've done this before, once, and it didnt then. Sadly I no longer have the code.

I get this error

The form field "C:\CFusionMX7\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\neotmp10795.tmp" did not contain a file.

Now according to the CFMX7 WACK using #getDirectoryFromPath(getBaseTemplatePath())# should put it int he same directory as the template. But obviously it doesnt.

Does anyone have any ideas why this doesnt work????

-desperate-
TOPICS
Advanced techniques

Views

516

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Nov 06, 2006 Nov 06, 2006
Ahhh... got it working.

When I upload the file the string truncated error was because the path was longer than the space it was trying to write it into in the db. It was trying to write the old, client side file path. when I needed to use #cffile.clientfile# as the filename value int he insert query.

Votes

Translate

Translate
LEGEND ,
Nov 06, 2006 Nov 06, 2006

Copy link to clipboard

Copied

<CFFILE
DESTINATION="#getDirectoryFromPath(getBaseTemplatePath())#"
ACTION="upload"
NAMECONFLICT="overwrite"
FILEFIELD="#FORM.FileName#"
ACCEPT="image/gif, image/jpeg, image/jpg, image/pjpeg" >



NO pounds or "form." in the filefield parameter. It is resolving
form.fileName and expecting to get a form field name for a value.

<CFFILE
DESTINATION="#getDirectoryFromPath(getBaseTemplatePath())#"
ACTION="upload"
NAMECONFLICT="overwrite"
FILEFIELD="FileName"
ACCEPT="image/gif, image/jpeg, image/jpg, image/pjpeg" >

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 06, 2006 Nov 06, 2006

Copy link to clipboard

Copied

Thanks. Thats changed it a little


I now get the same error but with at least the filename included

The destination "C:\CFusionMX7\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\http:\127.0.0.1:8500\blanksystem\images\storyimages\484010_business_man_modified[1].jpg" specified in the CFFILE tag is invalid.

Where is it getting all this "C:\CFusionMX7\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\" crap from?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 06, 2006 Nov 06, 2006

Copy link to clipboard

Copied

By a process of elimination I have commented out parts of the code on the action page to discover that the filename is a problem, causing this error while executing the query.

"String or binary data would be truncated."

I get this error now and again and its usually easy to solve. What am I missing!!

WHen I output the filename variable thus

<cfoutput>#FORM.FileName#</cfoutput>

I get

"C:\CFusionMX7\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\neotmp10835.tmp"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 06, 2006 Nov 06, 2006

Copy link to clipboard

Copied

C:\CFusionMX7\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\http:\127.0
.0.1:8500\blanksystem\images\storyimages\484010_business_man_modified[1].jpg



That is the file where the webserver put the file uploaded from the
client. This is what coldfusion needs to move the file to a location of
your choosing.

When uploading a file, coldfusion does not read from the client machine,
that would be a huge security hole. The process goes like this.

User submits form with completed file input field.

Browser retrieves selected file and sends to server as part of the
request response, (thus the multipart/form-data parameter of the form).

Web server (IIS|Apache|ect) parse the file data out of the response
header and saves it in a temporary file, such as the one described above.

Web server hands off handle of this temp file to application server, in
our case Cold Fusion.

ColdFusion follows the directions of the <cffile ...> tag to copy this
temporary file to a permanent location.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 06, 2006 Nov 06, 2006

Copy link to clipboard

Copied

OK Thanks.

I have the cfflie uploading the image to the correct folder. but I need the name of the file that has just been uploaded (ie man.jpg)
to update the database with

But when I output FORM.FileName

I get

"C:\CFusionMX7\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\neotmp10835.tmp"

Surely it should be the name of the file. If not, how do I get the filename value to save in my database so I can use it later?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 06, 2006 Nov 06, 2006

Copy link to clipboard

Copied

LATEST
Ahhh... got it working.

When I upload the file the string truncated error was because the path was longer than the space it was trying to write it into in the db. It was trying to write the old, client side file path. when I needed to use #cffile.clientfile# as the filename value int he insert query.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation