// Valid file Mime types / extension
$allowed_types = array(
"image/jpeg" => "jpg", "image/gif" => "gif"
// Add more types here if you like
);
// Set the maximum file size => 204800 = 200kb
$maxfilesize = 5048000;
// Is it under the allowed Max file size?
if($_FILES['userfile']['size'] > $maxfilesize) {
die("<center><font color=\"#000000\" size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">File is too large!</font></center>");
}
// Where are the files going?
$uploaddir = $_SERVER['DOCUMENT_ROOT'] . "/dev/photos/";
// What is the files temporary name?
$file = $_FILES['userfile']['tmp_name'];
// What is the files actual name?
$filename = $_FILES['userfile']['name'];
// Check to see if the file allready exists?
if(file_exists($uploaddir . $filename)) {
die("<center><font color=\"#000000\" size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">A file with that name already exists on this server.</font></center>");
} else {
// If the file does not already exist, copy it.
copy($file, $uploaddir.$filename) or die("<center><font color=\"#000000\" size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">Could not copy file.</font></center>");
}
Im not sure whats wrong in this script.
When the script is Executed I either get
"A file with that name already exists on this server."
or
"Could Not Copy"
everything is turned on from the server side as well
check the 'error' key in the $_FILES['userfile'] array. It will show you a number which refers to an error that occured during the file upload. Explanations of the errors can be found here: http://be.php.net/manual/en/features...oad.errors.php
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks