Jump to content

[SOLVED] uploading files via Php


divadiva

Recommended Posts

Experts

 

I have two files upload_file.php and uploader.php in a directory Upload.

 

First file is upload_file.php

 

<form enctype="multipart/form-data" action="uploader.php" method="POST"> 
   <input type="hidden" name="MAX_FILE_SIZE" value="1000" /> 
   Upload File: <input name="uploadedfile" type="file" /> <br /> 
   <input type="submit" value="Upload File" /> 
   </form> 

 

 

Second file uploader.php

 

<?php 
$target_path = "uploads/"; 

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
print"$target_path";
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {



   echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; 
} else{ 
    echo "There was an error uploading the file, please try again!"; 
}?> 

 

When I run upload.php I get  the basic form which asks me to select a file .When I select a file it gives me this error:

 

Warning: move_uploaded_file(uploads/gagantest.txt) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\wamp\www\upload\uploader.php on line 6

 

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\wamp\tmp\php6E.tmp' to 'uploads/abc.txt' in C:\wamp\www\upload\uploader.php on line 6

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

 

 

I have been trying to resolve it bbut unable to do that so far.Please help me out.

 

Link to comment
https://forums.phpfreaks.com/topic/111547-solved-uploading-files-via-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.