Solved

CFfile upload question!

Posted on 2002-04-04
6
195 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:iqbalwali
Comment Utility
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
Comment Utility
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
Comment Utility
good catch techy6.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now