nblackwood Posted September 12, 2010 Share Posted September 12, 2010 How would I copy an array of selected files? I know how to list them using a 'for' loop, and how to separate them using a 'foreach' loop, but I am unable to get a checkbox array to copy to a destination folder. Help is appreciated. Link to comment https://forums.phpfreaks.com/topic/213236-copy-array-of-files/ Share on other sites More sharing options...
Hypnos Posted September 12, 2010 Share Posted September 12, 2010 Copy them one at a time with a foreach loop and copy(). http://php.net/manual/en/function.copy.php Link to comment https://forums.phpfreaks.com/topic/213236-copy-array-of-files/#findComment-1110335 Share on other sites More sharing options...
nblackwood Posted September 12, 2010 Author Share Posted September 12, 2010 It didn't work. I get the "Failed to copy" error. I'm using the following code: <?php if(isset($_POST['Copy'])) { foreach($_POST['select'] as $Source) { copy($Source, "C:\\test") or die('Failed to copy'); } } ?> Link to comment https://forums.phpfreaks.com/topic/213236-copy-array-of-files/#findComment-1110354 Share on other sites More sharing options...
Hypnos Posted September 12, 2010 Share Posted September 12, 2010 Looks right. Try changing your die() to this: die("Failed to copy $Source"); and see what it says. Link to comment https://forums.phpfreaks.com/topic/213236-copy-array-of-files/#findComment-1110359 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.