我正在尝试将图像移动到服务器端的 tmp 目录,然后将其从 tmp 文件夹发送到客户端,但事情并不完全正常。这是我目前拥有的。
//this is where the image resides permanently
$imgdirectory = "../" . $ms . "msimages/" . $img_filename;
//here I'm trying to get the contents of the img from its permanent location
$content = file_get_contents($imgdirectory);
//here I'm trying to create a new temporary file
file_put_contents('/tmp/img.jpg', $content);
...
echo "img {background:url(\"/tmp/img.jpg\")-" . $xleft . "px -" . $ytop . "px";}"; this is the css trying to use file that is supposed to be in the temp folder
这是页面加载时我得到的css输出
img#{width:631px;height:453px;background:url("/tmp/img.jpg")-144px -112px;}
但不幸的是,没有文件,/tmp/img.jpg
所以某些东西一定不能与file_put_contents
404 image not found
顺便说一句,我没有收到关于put contents
/tmp 权限的任何错误,
任何建议表示赞赏。