douhao2548 2012-08-01 00:36
浏览 49

如何在上传文件的同一路径中保存文件,PHP?

Use PHP , my concept is: User upload image by submit form, then script overlay logo watermark. I want to save the modified image to the same location of original image (on user's computer). My code now is something like this:

<form name="form1" method="post" action="watermark.php" enctype="multipart/form-data">

Select file:
<input type="file" name="uploadfile"/>
<input type="submit" value="submit">

</form>

How to know the path of original file to save the modified image in the same location?

  • 写回答

2条回答 默认 最新

  • douhao5280 2012-08-01 00:40
    关注

    You can't save it directly on user's computer (using HTML) as that would be a violation of - everything. Instead, you can provide the file for download after modification. Provided, you are using GD for watermarking, the code is simple (but not perfect and should be considered just a lead):

    // perform some ops with $img
    
    Header('Content-Type: image/jpeg');
    Header('Content-Disposition: attachment; filename=' . $filename);
    
    imagejpeg($img);
    
    imagedestroy($img);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?