Select Categories Below
Advertisement
Start Your Own Q&A Site
Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.
Status: Closed Points: 75 Time: 14:10 - Feb 02, 2009
david
Hi, I need to let a user upload a file and then save it in a specific location on the server. I'm using PHP and I'm not sure how to do this. Hope you can help. David
Categories:
Add Categories
When adding more than one category, separate them with commas.
shashi.programmer
Date:: Feb 03, 2009
Time:: 01:28
Below is full file you can copy and paste and try it and one more thing create "uploaded" folder in the same directory where you want to upload the file:.... <?php if(isset($_POST['sub'])) { $target_path = "./uploaded/"; $target_path = $target_path.basename($_FILES['files']['name']); if(move_uploaded_file($_FILES['files']['tmp_name'], $target_path)) { $file_name=$_FILES['files']['name']; echo $file_name." has been uploaded."; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-t... <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form name="addcom" method="post" action="" enctype="multipart/form-data"> <table> <tr> <td>Files</td> <td><input name="files" type="file" id="files" /></td> </tr> <tr> <td align="center"> </td> <td> <input type="hidden" name="sub" /> <input name="submit" type="submit" class="maintext" value="Submit"> </td> </tr> </table> </form> </body> </html>
Time:: 02:03
Thanks shashi, that works perfect.
Question Answered
This question has been closed, and points have been rewarded to the following experts:
You're welcome however to comment or give additional information or if you wish, you have the ability to write a Tutorial in the Tutorial Area.
Answer this Question
New User
Email:
Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address
Registered User
Username:
Password:
Forgot Your Password?
Enter your email address below and we will resend your login information to you.
Login Information Sent
Date:: Sep 03, 2009
Time:: 04:09
<?php /*********************************************** * Snippet Name : File Uploader * * Scripted By : Shashidhar Kumar * * Website : http://www.shashionline.in * * Email : shashi@shashionline.in * * License : GPL (General Public License) * ***********************************************/ if(isset($_POST['sub'])) { $target_path = "./uploaded/"; $target_path = $target_path.basename($_FILES['files']['name']); if(move_uploaded_file($_FILES['files']['tmp_name'], $target_path)) { $file_name=$_FILES['files']['name']; echo $file_name." has been uploaded."; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-t... <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>File Upload</title> </head> <body> <form name="addcom" method="post" action="" enctype="multipart/form-data"> <table> <tr> <td>Files</td> <td><input name="files" type="file" id="files" /></td> </tr> <tr> <td align="center"> </td> <td> <input type="hidden" name="sub" /> <input name="submit" type="submit" class="maintext" value="Submit"> </td> </tr> </table> </form> </body> </html>
Click here to see the Answer Discussion that preceded this tutorial.
Login to rate this tutorial: Good | Bad
Questions
How to download file with private access from Amazon s3 server, in c#.. Any e...
You have 100 characters to use
Rank
Expert
Points
1.
10279
2.
6493
3.
5596
4.
4848
5.
3487
6.
2840
7.
2770
8.
2303
9.
1820
10.
917
Register today to share your knowledge with the community and be recognized and rewarded for your contributions.
Register Here
"Psst, Quomon is a great site. Pass it on." Tell a Friend | Link To Us | Save to Delicious | Digg it
Language Options
English:
Español:
Sponsors
Questions and Answers Software