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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to upload files?

Status
Not open for further replies.

oceandeep

IS-IT--Management
Jul 6, 2000
69
0
0
GR
If anybody here can give me some tips how to upload files to the server by using coldfusion? It seems I can do this by only using the absolute path, but I want to use the relative path. And how can I rename the file name uploaded?
Thanks!

Albert [sig][/sig]
 
HI,

Using relative-path can be done to store the
base-path in an application-variable in application.cfm:

<cfset application.base = &quot;c:\inetpub\
to upload the file:

<cffile action=&quot;UPLOAD&quot;
filefield=&quot;img1&quot;
destination=&quot;#application.base#\fotos\&quot;
nameconflict=&quot;OVERWRITE&quot;
accept=&quot;image/gif&quot;>

To rename the file goes like this:

<cffile action=&quot;UPLOAD&quot;
filefield=&quot;img1&quot;
destination=&quot;c:\inetpub\ nameconflict=&quot;MakeUnique&quot;
accept=&quot;image/gif&quot;>
There is a file-object 'serverFile' that holds
the generated name.
<cfset xx = #cffile.serverFile#>
With xx you can make an entry in a database to retrieve
this file later.

If you insist on naming this file exactly as you want, you
can rename the file after upload with 'makeUnique':

<cffile action=&quot;rename&quot; source=&quot;#application.base#\adirectory\#xx#
destination=&quot;yourname&quot;>

Hope this helps

Toon [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top