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

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决