Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cffile uploading to /var/tmp ?

Status
Not open for further replies.

kelani

MIS
Nov 29, 2000
44
US
I have a photo upload processor that looks like this..

<form action=&quot;addphoto.cfm?Save=&quot; enctype=&quot;multipart/form-data&quot; method=&quot;post&quot;>
<input type=&quot;file&quot; name=&quot;photo&quot;>
<input type=&quot;text&quot; name=&quot;caption&quot; size=&quot;25&quot; maxlength=&quot;200&quot;>
</form>

The update/insert query is as follows:

<cffile action=&quot;UPLOAD&quot; filefield=&quot;Photo&quot; destination=&quot;/home/kelani/public_html/dir_to/photos&quot; nameconflict=&quot;MAKEUNIQUE&quot;>

<cfquery name=&quot;db_insert&quot; datasource=&quot;dbname&quot; dbtype=&quot;ODBC&quot; username=&quot;username&quot; password=&quot;pswd&quot; dbserver=&quot;localhost&quot; dbname=&quot;dbname&quot;>
UPDATE users SET photo='#form.photo#', cap='#cap#' WHERE ID='#form.id#'
</cfquery>

the file uploads to the correct directory, but the link in my table is always defaulting to

/var/tmp/filename.jpg

What am I missing here?

kelani
 
it's because the input file links to /var/tmp/filename.jpg whatever the actual path is
and what you insert in the db is the input file path (it's normal it uploads correctly, as the source path is correct anyway, i mean there is actually a copy of your image in the var/tmp directory)

but i don't know how to fix that. I might be searching today, but it's not sure i have the time to, so if anyone knows how to, please tell us (i'm intersetd in doing this as well !!)
 
Someone on another form posted this solution, well, part of it, anyway..

You set it to the new variable FILE/ServerDirectory and FILE.ServerFile. The problem now is getting the two parameters combined into one variable. This is what he proposed , which does not seem to work..

<CFIF FILE.FileWasSaved Is True>
<CFSET theRealFileName = FILE.ServerDirectory &amp;&quot;/&quot;&amp; FILE.ServerFile>

<cfquery name=&quot;db_insert&quot; datasource=&quot;dbname&quot; dbtype=&quot;ODBC&quot; username=&quot;user&quot; password=&quot;pswd&quot; dbserver=&quot;localhost&quot; dbname=&quot;dbname&quot;>

UPDATE users SET photo='#theRealFileName#', cap='#cap#' WHERE ID='#form.id#'
</cfquery>


So, the problem is somewhere in this:

<CFSET theRealFileName = FILE.ServerDirectory &amp;&quot;/&quot;&amp; FILE.ServerFile>

Any ideas?
 
what happens exactly ? is that the &quot;/&quot; that doesn't append correctly ? if so, you should use the chr(??) <-- have to find the code for / ;-) )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top