我试图将图像移动到服务器端的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
BTW工作,我在/ tmp,
中没有收到关于put contents
权限的任何错误非常感谢。
如果你没有给脚本读取权限,或访问权限,可以返还找不到文件。 – 2012-07-08 17:09:44