Solved

CFfile upload question!

Posted on 2002-04-04
6
201 Views
Last Modified: 2013-12-24
Hi,

I want my site vistors to be able to upload there pictures on the server. I am using the following codes but it is not working. Can some body tell me what's wrong with it?

<!-- if form submitted -->
<cfif isdefined('Form.picture')>
<-- !find the current directary to same the picture -->
<cfset
CurrentDir=GetDirectoryFormPath(ExpandPath("*.*"))>
<cffile
action="upload"
filefield="picture"
destination="#CurrentDir#"
accept="text/html"
nameconflict="MakeUnique">
</cfif>
<!-- show the form -->
<form action="upload.cfm" method="post" enctype="multipart/form-data"></form>
Please Choose a file to upload
<br>
<input type="File" name="picture" size=40>
<br>
<input type="submit">
</form>

Thank you!
0
Comment
Question by:iqbalwali
  • 3
  • 2
6 Comments
 
LVL 19

Expert Comment

by:cheekycj
ID: 6919463
what errors are you getting?

are you using this as your basic example:
http://cfhub.com/advanced/cffile/upload.cfm

try outputing file attributes after you upload:

<cfoutput>#File.FileWasSaved#,#File.ServerFileName#,#File.FileExisted#</cfoutput>

What is shown.

CJ
0
 

Author Comment

by:iqbalwali
ID: 6919544
CJ,

It is not showing me any error. When i click the uplaod button and choose the file from other dirctory on my PC and say ok and click again on upload button to upload it, nothing will happene and no error page. It won't take me to any page it keeps me on the same form page.

0
 
LVL 19

Expert Comment

by:cheekycj
ID: 6919549
That is the way the code is written.

If you want it to goto a another page.. write the code that way.

Right now.. it uploads the file and displays the form again.

If you want to change it try:

<!-- if form submitted -->
<cfif isdefined('Form.picture')>
<-- !find the current directary to same the picture -->
<cfset
CurrentDir=GetDirectoryFormPath(ExpandPath("*.*"))>
<cffile
action="upload"
filefield="picture"
destination="#CurrentDir#"
accept="text/html"
nameconflict="MakeUnique">
Upload Successful!
<cfelse>
<!-- show the form -->
<form action="upload.cfm" method="post" enctype="multipart/form-data"></form>
Please Choose a file to upload
<br>
<input type="File" name="picture" size=40>
<br>
<input type="submit">
</form></cfif>

CJ
0
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 

Author Comment

by:iqbalwali
ID: 6919636
CJ,

What I meant that it is not upload the file.  I think something is wrong with codes. My aim is to upload the file. I tried it also on the server but nothing happenend.

0
 
LVL 1

Accepted Solution

by:
techy6 earned 10 total points
ID: 6920651
Hi iqbalwali,

One very minor thing I noticed was a typo in your <cfset CurrentDir=GetDirectoryFormPath(ExpandPath("*.*"))> statement - you've put FormPath instead of FromPath.

techy6.
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 6920721
good catch techy6.
0

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

Suggested Solutions

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.

828 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