how to copy media files with php?

reis

New member
How do you copy all file types from any directory to a fixed directory. i tried (and succeeded) but it only worked with text files. this is what i have: (also i made it so the user can browse for a file then click copy)

$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

$source = $fileName;
$destination = "library/" . $fileName;

$data = file_get_contents($source);

$handle = fopen($destination, "w");

fwrite($handle, $data);
fclose($handle);
 
Back
Top