By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

File Upload Error

chunk1978
100+
P: 224
hi there...

i have the following codes (HTML and PHP) on my Apache Localhost:

HTML: titled "Form.html"
Expand|Select|Wrap|Line Numbers
  1. <form enctype="multipart/form-data" action="uploader.php" method="POST">
  2. <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
  3. Choose a file to upload: <input name="uploadedfile" type="file" /><br />
  4. <input type="submit" value="Upload File" />
  5. </form>
  6.  
PHP: titled "uploader.php"
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $target_path = "uploads/";
  3.  
  4. $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
  5.  
  6. if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
  7.     echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
  8.     " has been uploaded";
  9. } else{
  10.     echo "There was an error uploading the file, please try again!";
  11. }
  12. ?>
  13.  
i've also created a folder called "uploads" in the same directory as the .html and .php files.

the problem i'm having is that i always get the message:

"There was an error uploading the file, please try again!"

i don't know what i'm doing wrong... this is the most basic php upload script... does Apache not allow files to be written to the localhost folders? or maybe the php script is wrong?

anyone?
Apr 25 '07 #1
Share this Question
Share on Google+
3 Replies


P: 10
Hi,

The Code what you wrote is correct and its working.Execute once again!!

prasanna
Apr 25 '07 #2

Motoma
Expert 2.5K+
P: 3,235
You probably have permissions set up wrong in your file system, therefor move_uploaded_file() is failing.
Apr 25 '07 #3

chunk1978
100+
P: 224
You probably have permissions set up wrong in your file system, therefor move_uploaded_file() is failing.
hi motoma, thanks for replying... i've read something about changing file permissions to 777, but i have zero idea how i could do this with Apache on my localhost... i don't use FTP to transfer files, while i read that permissions can be changed via FTP.
Apr 25 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.