0

I have some problem with the upload of image with php. I don't know why but i'm not able to complete the upload. Here is my code :

<?php

error_reporting(E_ALL);
$uploaddir = '/uploads/';
$uploadfile = $uploaddir . basename($_FILES['files']['name']['0']);

if (move_uploaded_file($_FILES['files']['name']['0'], __DIR__.'/../ticket/'. $_FILES["files"]['name']['0'])) {
    echo "Uploaded";
} else {
   echo "File was not uploaded";
}

echo 'Some Information:';
print_r($_FILES);

print "</pre>";

?>

This is what I received when I call this services

 File was not uploadedSome Information:Array
 (
[files] => Array
    (
        [name] => Array
            (
                [0] => IMG_20180531_223116_725.jpg?1527806109166
            )

        [type] => Array
            (
                [0] => multipart/form-data
            )

        [tmp_name] => Array
            (
                [0] => /membri/.dummy/temp/phpM2iSBN
            )

        [error] => Array
            (
                [0] => 0
            )

        [size] => Array
            (
                [0] => 112903
            )

    )

)

Thank you if you can help me.

1 Answer 1

1

you want to move the file in the local temp directory

$_FILES['files']['tmp_name']['0'] not the file name

so:

if (move_uploaded_file($_FILES['files']['tmp_name']['0'], __DIR__.'/../ticket/'. $_FILES["files"]['name']['0'])) {
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.