I'm using this script to upload JPEG/PJPEG files to my server.
The $userfile is: From HTML Form <input name="userfile" type="file" size="46">
It's not really difficult to change the code to best fit your needs.
Good Luck.
if($userfile) {
$path = "path/to/your/dir/";
$max_size = 50000;
if (!isset($HTTP_POST_FILES['userfile'])) { }
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
if ($HTTP_POST_FILES['userfile']['size']>$max_size) { echo "The file is too big<br>\n"; exit; }
if (($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg")) {
$fname = "filename.jpg";
$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path . $fname);
if (!$res) {
echo "upload failed!<br>\n"; exit;
} else {
print "Upload OK";
}
} else { echo "Wrong file type<br>\n"; exit; }
}
}