图像上传并保存在一个php脚本中
我想上传一个图像从远程服务器到我的当前服务器(服务器和后端迁移)我使用的是laravel 4,这是一个一次性使用的脚本,所以不需要担心保护它图像上传并保存在一个php脚本中,php,image,laravel-4,Php,Image,Laravel 4,我想上传一个图像从远程服务器到我的当前服务器(服务器和后端迁移)我使用的是laravel 4,这是一个一次性使用的脚本,所以不需要担心保护它 if (strpos($check_image_arr['url'], '/product/')) { try { if (! file_exists ( "$destinationPath")) {
if (strpos($check_image_arr['url'], '/product/'))
{
try
{
if (! file_exists ( "$destinationPath"))
{
mkdir("$destinationPath", 0777);
}
copy($check_image_arr['url'],$destinationPath."temp.jpg");
echo "<img src=$destinationPath"."$filename >";
$file = file_get_contents($destinationPath);
$destinationPath = public_path().'/img/product_images/'.'$check->id';
$filename = '$check->id'.".png";
$uploadSuccess = $file->move($destinationPath, $filename);
die;
}
catch (Exception $e)
{
echo "$e";
die;
}
当前的输出是“调用非对象上的成员函数move()”为什么不压缩文件夹并在目标位置解压,因为这是一次性传输?尝试利用laravel任何图像输入和定义的图像输出除了在2台服务器上加载之外,没有任何优势,但祝你好运;)问题是这是一个应用程序的后端,他们需要PNG的工作,所以我需要抓取当前图像位置的url(从数据库中获取,因为所有图像位置都非常复杂),然后我需要将该图像上传到一个静态位置(见上面的复制功能)这很好,然后我需要抓取该图像,使其成为PNG,并将其命名为递增数字,这就是我遇到的问题。
if (strpos($check_image_arr['url'], '/product/'))
{
if (! file_exists ( "$destinationPath"))
{
mkdir("$destinationPath", 0777);
}
copy($check_image_arr['url'],$destinationPath."temp.jpg");
imagepng(imagecreatefromstring(file_get_contents(__DIR__."/img/product_images/"."$check->id"."/"."temp.jpg")),"temp.png");
copy("temp.png",$destinationPath.$filename);
}