How to read and write images and video with PHP? [closed]
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 questionI 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
精彩评论