Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CFfile upload question!

Posted on 2002-04-04
6
Medium Priority
?
207 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
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 

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 40 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Loops Section Overview
Suggested Courses

782 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