V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
chend
V2EX  ›  问与答

php 复制两次图片 copy() 只有一张?

  •  
  •   chend · Dec 16, 2015 · 2734 views
    This topic created in 3796 days ago, the information mentioned may be changed or developed.

    浏览器: 微信浏览器

    前端: 前端 input file 按钮,选择图片

    处理逻辑

    当图片宽度<=400 , php 调用 copy() 两次,生成 aaa.jpg 和 aaa.jpg_large.jpg 图片 。 if ( copy() && copy() ){} //copy 失败 die(),回调处理
    当图片宽度>400, 调用 imagecopyresampled() 生成宽度 200 和 400 的两张图片. 两次调用 gd 库压缩,
    if ( !imagecopyresampled() ){} //压缩失败 die(), 回调处理

    问题

    管理后台发现有用户传的图片只生成了 aaa.jpg_large.jpg 这一张,。。。而且 回调没有报错,正常处理

    案例

    用户上传的 宽度<400 的图片出现这个问题, 因为用的 copy ,直接把图片拿到自己和组里其他人的手机上传, 没有出现问题。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   994 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 19:44 · PVG 03:44 · LAX 12:44 · JFK 15:44
    ♥ Do have faith in what you're doing.