douke9379 2012-12-17 21:32
浏览 83

PHP:在上传时在文件名末尾添加数字(计数1)? [关闭]

i have an image upload script and i have the file name set to save as 'thumb_pic.jpg' on upload. But i want users to be able to upload a maximum of 8 different photos, with the same name but i just want to add 1-8 at the end of each file name like so:

'thumb_pic1.jpg', 'thumb_pic2.jpg' etc.

Here's the snippet of my code which is where the file name is set. Can anyone tell me what i'd need to add to do what i'm trying to do? Thanks.

 $filename = $_POST['value'] ? $_POST['value'] :
            $folder . 'thumb_pic.jpg'; 
  • 写回答

2条回答 默认 最新

  • duanjiao5082 2012-12-17 21:34
    关注
    $filename = .... $folder . 'thumb_pic' . $i . '.jpg';
                                          ^^^^^^^^
    

    where $i is your 1-8 value. Generating it is up to you, since you don't specify how your file upload form or server-side handling scripts are constructed.

    评论

报告相同问题?

悬赏问题

  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教