Solved

CFfile upload question!

Posted on 2002-04-04
6
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

 

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

739 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