|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
I have a form which I can browse for a file and upload it to another folder on my local machine.e.g c:/ etc.
The coldfusion bible only gives examples of local machine for destination but I need to upload to a server. I have tried the http address but the file doesn't upload. I have also tried a path name e.g ./images/house.jpg but this doesn't work either. Can you help. Cheers Peter |
|
#2
|
|||
|
|||
|
If you want to let the user upload a file from their local system to the ColdFusion server, use CFFILE:
http://livedocs.macromedia.com/cold...5.htm#wp3540091
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
destination
I have it all working using cffile but only to a local directory. Should it work on hosting server using relative path e.g ./images/full.jpg or do you need http://www.hostname/images.full jpg for example.
neither seem to work. If i use http as above do I need to supply username and password in the url? Cheers peter |
|
#4
|
|||
|
|||
|
The destination attribute of CFFILE is an absolute path on the SERVER. This is from the documentation link I sent earlier:
destination: Pathname of directory in which to upload the file. If not an absolute path (starting a with a drive letter and a colon, or a forward or backward slash), it is relative to the ColdFusion temporary directory, which is returned by the GetTempDirectory function. So you could use a destination like "C:\cfusionmx\wwwroot\mysite\myuploadfolder\", which would put the file into that directory on the server. If you still can't get this to work, try posting your code so we can see what you're doing incorrectly. |
|
#5
|
|||
|
|||
|
still having probs
I am still having problems getting an image to upload when I ftp the file to the server. I have supplied the code below.
It works fine using wwwroot on my local machine but not on the server. Hope you can help. Cheers peter <style type="text/css"> <!-- .style1 { color: #000066; font-weight: bold; } .style2 {color: #990000} --> </style> <cftry> <cffile action = "upload" fileField = "FileContents" destination = "C:\Inetpub\wwwroot\Bernada_golf\images\resale_thumb" accept = "image/pjpeg, image/gif, image/bmp, image/jpg," nameConflict="overwrite"> <div align="center" class="style1"> <p><img src="images/upload%20success.jpg" width="287" height="43"></p> <p>Your Thumbnail image has been successfully uploaded to the server. <br> <br> Please make sure you have added the image file name into the insert form. <br> <br> <span class="style2">Please use the back button to upload more images as required.</span> </p> </div> <table width="669" border="0" cellspacing="2" cellpadding="2"> <tr> <td width="449"><div align="center"> <input name="button" type=button onClick="javascript:self.close();" onKeyPress="javascript:self.close();" value="Close Window"> </div></td> </tr> </tr> </table> <cfcatch type = "any"> <div align="center" class="style1"> <p><img src="images/upload%20error.jpg" width="287" height="43"></p> <p>File upload didn't work or the server could not accept your file type. <br> <br> Please make sure you have browsed for a file to upload <br> <br> Only files of type .jpeg, .jpg, .gif and .bmp files will be accepted. <br> <br> <span class="style2">Please use the back button to retry.</span> </p> </div> <table width="457" border="0" cellspacing="2" cellpadding="2"> <tr> <td width="449"><div align="center"> <input name="button" type=button onClick="javascript:self.close();" onKeyPress="javascript:self.close();" value="Close Window"> </div></td> </tr> </tr> </table> </cfcatch> </cftry> |
|
#6
|
|||
|
|||
|
If it's working fine on your local machine, but not to the server, it seems permissions related. Double check, and be sure that you have rights to write to, the absolute path you're specifying on the server.
|
|
#7
|
|||
|
|||
|
I have a question concerning permission on the destination folder. I was able to get <cffile> to work as long as there was no restriction on the folder.
My problem is that my client does not want to have this folder available to all users due to security issues. They want to create an owner account for the destination folder and only this system account will have write access to the folder. Is there any way I can get cffile to work in this situation? Other alternatives will also be helpful. Thanks in advance, AOne. |
|
#8
|
|||
|
|||
|
Consider the creation of an OS/Domain user specifically for ColdFusion. Then set the CF services to use this username and password. On Windows you can configure this is the services manager. I'm not sure how it's done on UNIX but I am positive it can be done.
Once you have CF using its own account, you can secure the directory and only allow the CF account to read/write files to that directory. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > destination folder |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|