nightscream
New Member
- Messages
- 948
- Reaction score
- 0
- Points
- 0
I'm creating my own upload script but It won't work
if I want to upload something i get
File '' not uploaded
It's something with the $_FILES i think but don't know how to fix it
if I want to upload something i get
File '' not uploaded
It's something with the $_FILES i think but don't know how to fix it
PHP:
if( isset( $_POST['Upload'] )) {
$upload_dir = $_SERVER['DOCUMENT_ROOT'] . "images/";
$MaxFileSize = 800000000;
$filename = $_FILES['file']['name'];
$filesize = $_FILES['file']['size'];
$filetmpname = $_FILES['file']['tmp_name'];
$allowed_types = array( "jpg", "gif", "png" );
$filetype = substr($filename, -3, 3);
//$Thumb = $_POST['Thumbnail'];
//$Water = $_POST['Watermarking'];
if($filename) {
echo 'test';
$error = 0;
if(($filesize > $MaxFileSize) | $filesize = 0 ) {
$error = 1;
$errmsg .= "Your File is to large, (Max File size: 8MB)";
}
if( !in_array( $filetype, $allowed_types )) {
$error = 1;
$errmsg .= "Your File is the wrong type, (Allowed Types: Gif, Jpg, Png)//change to the allowed types";
}else {
$error = 0;
}
if( $error = 1 ) {
die( "$errmsg" );
}else{
$num = rand( 1, 9999 );
$new_filename = $num.$filename;
$upload = move_uploaded_file($filetmpname, "$upload_dir.$new_filename");
if($Thumb = 1 ) {
CreateThumb($filetmpname);
}
if($Water = 1 ) {
CreateWatermark($filetmpname);
}
if( $upload ) {
echo 'Upload Succesfull';
//echo "<meta http-equiv='refresh' content='0'; URL='?image=$upload_dir.$new_filename'>";
}else {
die( "Cound not upload the file, please try again" );
}
}
}else{
echo "File '$filename' not uploaded";
}
}
?>
Last edited: