dsn1327 2015-06-03 14:30
浏览 20

仅重命名文件的一部分

So far I have it so it changes it on the website, but how would I make it change the file's name on the server?

foreach(glob("vacation/*.jpg") as $image) {
  $tmpName = explode("_", $image);
  $tmpName = explode("~", $tmpName[1]);
  $md5 = md5($tmpName[0]);
  print "<p>{$md5}</p>";
}

This is what I have so far, it takes IMG_0401~timestamp.jpg and on the website shows it as IMG_99f97481f8214da999e3ccbe116f5334~timestamp.jpg

I want to actually rename the file to that

  • 写回答

1条回答 默认 最新

  • dongxiusuo9881 2015-06-03 14:40
    关注

    You need to use PHP's rename function:

    http://php.net/manual/en/function.rename.php

    foreach(glob("vacation/*.jpg") as $image) {
      $tmpName = explode("_", $image);
      $tmpName = explode("~", $tmpName[1]);
      $md5 = md5($tmpName[0]);
      print "<p>{$md5}</p>";
      rename($image, $md5);
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100