这行代码适合我本地:
$copythumb = copy($externalsource, getcwd().'\\img\\covers\\'.$id.'thumb.jpg');
if (!$copythumb) {echo 'Couldn\'t add thumbnail';}
但是当我将它上传到我的服务器时,我只是得到“无法添加缩略图”而且它没有被复制。
我试图将\\img\\covers\\
改为/img/covers/
而没有运气。
我也用dirname(realpath(__FILE__))
和$_SERVER['DOCUMENT_ROOT']
本地:
echo getcwd(); //returns D:\Server\www\project
服务器:
echo getcwd(); //returns /storage/content/xx/xxxxxx/xxx.com/public_html/project
如果有人可以提供任何帮助,我将非常感激!
答案 0 :(得分:0)
更改您的img或封面目录权限
<?php
// Read and write for owner, nothing for everybody else
chmod("/somedir/somefile", 0600);
// Read and write for owner, read for everybody else
chmod("/somedir/somefile", 0644);
// Everything for owner, read and execute for others
chmod("/somedir/somefile", 0755);
// Everything for owner, read and execute for owner's group
chmod("/somedir/somefile", 0750);
?>