duangaixing1509 2013-09-04 21:41
浏览 67
已采纳

PHP - 将图像资源上传到FTP

I'm trying to resize image and upload it to FTP server without saving it on local disc but I didn't find any method how to do that. Function ftp_fput obviously doesn't TAKE image resource as argument.

I'm trying to do this:

imagecopyresampled($canvas, $image, 0, 0, 0, 0, $width, $height, $oldWidth, $oldHeight);

ob_start();
imagejpeg($canvas);
$stream = ob_get_clean();

// ftp_->fput(imagecreatefromstring($stream));
ftp_->fput($stream);

Any help?

  • 写回答

1条回答 默认 最新

  • doushi1957 2013-09-04 21:55
    关注

    PHP doesn't have a function to write a string through ftp. You would have to write the file to disk and send it or you can use the php://memory or php://temp wrapper to write the data to memory and pass that to ftp_fput. There is a comment on the ftp_put manual page that has a simple function that flushes to a temp file.

    http://www.php.net/manual/en/function.ftp-put.php#83260

    There are a few comments on the ftp_fput manual page that cover this as well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分