iqbalwali
asked on
CFfile upload question!
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=GetDirectoryFor mPath(Expa ndPath("*. *"))>
<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-da ta"></form >
Please Choose a file to upload
<br>
<input type="File" name="picture" size=40>
<br>
<input type="submit">
</form>
Thank you!
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=GetDirectoryFor
<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-da
Please Choose a file to upload
<br>
<input type="File" name="picture" size=40>
<br>
<input type="submit">
</form>
Thank you!
ASKER
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.
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.
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=GetDirectoryFor mPath(Expa ndPath("*. *"))>
<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-da ta"></form >
Please Choose a file to upload
<br>
<input type="File" name="picture" size=40>
<br>
<input type="submit">
</form></cfif>
CJ
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=GetDirectoryFor
<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-da
Please Choose a file to upload
<br>
<input type="File" name="picture" size=40>
<br>
<input type="submit">
</form></cfif>
CJ
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
good catch techy6.
are you using this as your basic example:
http://cfhub.com/advanced/cffile/upload.cfm
try outputing file attributes after you upload:
<cfoutput>#File.FileWasSav
What is shown.
CJ