riderz wrote:
why not share one then
if ($Submit){
if ($_FILES['image']['name']==''){
$error_msg = 'Please select a file';
$error = 1;
}
if (!$error){
$uploaddir = 'userimages/';
$file_name = rand(1,999).$_FILES['image']['name'];
if ($_FILES['image']['size'] >= 30721) {
$error_msg = "Your file is larger than 30KB.";
$upload_error = 1;
}
$file_type = "image";
$image_type = $_FILES['image']['type'];
$pos = strpos($image_type, $file_type);
if ($pos === false) {
$error_msg = "You cannot upload files of this type";
$upload_error = 1;
}
$file_info = getimagesize($_FILES['image']['tmp_name']);
if(empty($file_info)) {
$error_msg = "The uploaded file doesn't seem to be an image.";
$upload_error = 1;
}
if (!$upload_error) {
move_uploaded_file($_FILES['image']['tmp_name'], $uploaddir.$file_name);
// YOUR MYSQL QUERY GOES HERE
if ($res) $error_msg = "Your file was uploaded sucessfully";
else $error_msg = "Error occured, please try again";
}
}
}
That is just a simple uploader to make sure that only images is uploaded. You can go further and allow all file types but then hide the upload directory and or make files only down loadable. I do both.
If anyone want the any file type up loader with the only down loadable script, make me an offer. I am running a business after all. 🙂
PS : The script above is only the upload part and does not include the HTML/XHTML Form