映像不会保存为实际映像文件,而是一个空白映像文件


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

谁能帮帮我?

当我尝试将图像保存在新的文件夹位置时,它会保存为空图像文件。我试图使用$_FILES['pic']['name'],但它没有做任何事情,所以我一直在使用$_GET['pic']。昨天还能用,但不知什么原因,现在不行了。你能不能看看我的代码,因为我不知道我哪里出错了

Thanks in advance:)

保存图像文件的代码:
<?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']将工作