dougui4325 2018-05-31 22:54
浏览 33
已采纳

PHP上传图片无效

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条回答 默认 最新

  • douhui8163 2018-05-31 23:06
    关注

    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'])) {
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
  • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
  • ¥15 写论文,需要数据支撑
  • ¥15 identifier of an instance of 类 was altered from xx to xx错误
  • ¥100 反编译微信小游戏求指导
  • ¥15 docker模式webrtc-streamer 无法播放公网rtsp
  • ¥15 学不会递归,理解不了汉诺塔参数变化
  • ¥15 基于图神经网络的COVID-19药物筛选研究
  • ¥30 软件自定义无线电该怎样使用