开发者

How to read and write images and video with PHP? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. 开发者_如何学编程

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 4 years ago.

Improve this question

I am creating a downloadable zip file. In that zip, I want to add php, html, and images and videos.

All of them are in other folders.

I can read and write PHP and HTML files from other files/folders.

But I don't know how to read and write (or move from one folder to anther folder) images and videos.


Please try this code

function move_files($dir)
{
  if(is_dir($dir))
  {
    if($handle = opendir($dir))
    {
      while(($file = readdir($handle)) !== false)
      {
        if($file != "." && $file != ".." && $file != "Thumbs.db"/*pesky windows, images..*/)
        {
          $sourcefile = $dir.$file;
          $destinationfile = 'Your New Location';
          if (!copy($sourcefile, $destinationfile)) {
              echo "failed to copy $file...\n";
          }
        }
      }
      closedir($handle);
    }
  }
}

move_files("folder/");


I you want to move files, see PHP manual: copy, unlink

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜