Php 图像不另存为实际图像文件,而是一个空白图像文件
谁能帮帮我吗 当我尝试将图像保存在新文件夹位置时,它会将图像保存为空图像文件。我尝试使用$\u文件['pic']['name'],但它没有任何作用,所以我一直在使用$\u GET['pic']。 它昨天还在工作,但由于某种原因现在不行了。 你能看一下我的代码吗?因为我不知道哪里出了问题 提前感谢:) 保存图像文件的代码:Php 图像不另存为实际图像文件,而是一个空白图像文件,php,image,get,save,magento-1.9,Php,Image,Get,Save,Magento 1.9,谁能帮帮我吗 当我尝试将图像保存在新文件夹位置时,它会将图像保存为空图像文件。我尝试使用$\u文件['pic']['name'],但它没有任何作用,所以我一直在使用$\u GET['pic']。 它昨天还在工作,但由于某种原因现在不行了。 你能看一下我的代码吗?因为我不知道哪里出了问题 提前感谢:) 保存图像文件的代码: <?php if (isset($_GET["formCheck"])){ if (isset($_GET["pic"]) ) { $link=
<?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 to post,然后$\u文件['pic']['name']
将正常工作有人能帮忙吗?