Siavash
Siavash

Reputation: 7853

upload succeeding but picture is not there

I have a php page that is supposed to store the uploaded image to my server. When I run this, I get the "Upload successful" message, but the picture has not been uploaded. What could it be?

update: can people please leave a comment as to why they down vote my question. I'm new here and I dont know why this question got down voted. thanks

<?

if(!empty($_FILES['uploaded_file'])) {
    if ($_FILES['uploaded_file']['error'] > 0 )
        echo "Error: " . $_FILES['uploaded_file']['error'] . "<br />";
    else{
        // Add the original filename to target path.  
        $target_path = 'MemberPics\\user'.$userid.'.jpg' ; 
        $success = move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path);

        if(!$success) {
            echo "There was an error uploading the file, please try again!";
        }else {
            echo "Upload successful, please go back to your home page";

        }       
    }
}   
 ?>

Upvotes: 0

Views: 56

Answers (1)

Devon Bernard
Devon Bernard

Reputation: 2300

I believe the problem you are running into is that you are saving the image in an incorrect location (An invalid one from the looks of your link syntax).

Either of these should work:

$target_path = 'MemberPics/user'.$userid.'.jpg' ; 

or

move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], "MemberPics/user" . $_FILES["uploaded_file"]["name"]);

Upvotes: 1

Related Questions