dou44481 2015-12-07 15:40
浏览 32
已采纳

使用Image_moo使用PHP上传文件

I have a function that suppose to get a image file from the POST request. I'm using image_moo as a external library to resize the image before saving.

Here's my function

$dest = $_SERVER['DOCUMENT_ROOT'] . '/refundstylesheet/uploads/images/' . $_FILES['upfile']['name'];
$temp_file = $_FILES['upfile']['tmp_name'];

$this->image_moo->load($temp_file)->resize(350,350)->save($dest, TRUE);

I don't get any error message, it simply doesn't save the image on the server.

echo $dest:** /var/www/html/refundstylesheet/uploads/images/image.png
echo $temp_file:** /tmp/phpFIQp6S

I did all the necessary verifications with the uploaded file before reachs this function.

  • 写回答

4条回答 默认 最新

  • doujiekeyan0622 2015-12-08 19:43
    关注

    I solved the problem installing php-gd extension. Ronny's comment helped me. Since image_moo library does some image editing it needs this dependency. You may install this dependency simply executing the command bellow (linux):

    apt-get install php5-gd
    

    Check if is installed with phpinfo() and restart apache.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化