0

Php Upload script

Wednesday, November 7, 2007

This script is 2 separate php files and a folder. The first piece of code is the form page, save as "upform.php".

The script is the second piece of code, save as "uploader.php". save both as .php files with 644 perms. create a folder called "data" with 777 perms in the same dir as the uploader.php script.

Below is the form code, save as upform.php (or whatever)


File to upload:






Below is the script, save as uploader.php:
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "data/$name");
}
}
?>

0 Responses to "Php Upload script"