-1
有人可以帮我吗?图像不保存为实际图像文件,而是空白图像文件
当我尝试将图像保存到新文件夹位置时,它会保存但是作为空白图像文件。我试图使用$ _FILES ['pic'] ['name']但它没有做任何事情,所以我一直在使用$ _GET ['pic']。 它昨天正在工作,但由于某种原因,它现在不是。 能不能请你看看我的代码,因为我不知道我要去哪里错了
感谢提前:)
代码以保存图像文件:
<?php
if (isset($_GET["formCheck"])){
if (isset($_GET["pic"])) {
$link= $_GET["pic"];
echo "name: " . $link . "<br>";
$extension = end(explode('.', $_GET["pic"]));
$hashedimg = md5($link.time()) . "." . $extension;
echo $hashedimg . "<br>";
$destdir = Mage::getBaseDir('media') . DS . 'library' . DS;
echo "dir: " .$destdir . "<br>";
$img=file_get_contents($hashedimg);
file_put_contents($destdir.substr($hashedimg, strrpos($hashedimg,'/')), $img);
echo "end: " . $extension . "<br>";
echo "fileloc: " . $destdir . $hashedimg . "<br>";
$fileloc = $destdir . $hashedimg;
$_GET["pic"] = $fileloc;
echo $_GET["pic"];
}
}
?>
任何人都可以请帮忙吗? – AN11