图像不会保存为实际图像文件,而是空白图像文件

Image does not save as the actual image file but a blank image file

有人可以帮我吗?

当我尝试在新文件夹位置保存图像时,它保存为空图像文件。我试过使用 $_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"];              
    }
}
?>

问题是因为我使用的是 method="GET" 而不是 POST。要修复它,请将 get 更改为 post 然后 $_FILES['pic']['name'] 将起作用