this is what i have now:
<?php
// USERFILE VARIABLES ----------------------------------------------
$UserFilePath = "files/";
$UserFileMax_size = 20000000; //20MB
$UserFileDomain = $_SERVER["HTTP_HOST"];
$FILE_EXTS = array('.zip','.gif','.jpg','.jpeg','.png','.mov','.avi','.mpg','.mpeg','.wmv','.wma','.mp3','.wav');
// THUMBNAIL VARIABLE ----------------------------------------------
$ThumbnailPath = "Thumbnails/";
$ThumbnailMax_size = 100000; //100KB
$ThumbnailDomain = $_SERVER["HTTP_HOST"];
$THUMBNAIL_EXTS = array('.gif','.jpg','.jpeg','.png');
// Display Form Start ----------------------------------------------
echo '<form action="' . "$PHP_SELF" . '" method="post" enctype="multipart/form-data" name="upload">
<b>: Location of File :</b><br>
<input name="userfile" type="file" id="userfile" size="37">
<br>
<b>: Thumbnail Image : </b><br>
<input name="Thumbnail" type="file" id="Thumbnail" size="37">
<input name="upload" type="submit" id="upload" value="Upload">
<input name="clear" type="reset" id="clear" value="Clear">
<br>
</form>';
// Display Form End ------------------------------------------------
// Combined Validation start ---------------------------------------
// IF file and thumbnail is_uploaded_file
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name']) && is_uploaded_file($HTTP_POST_FILES['Thumbnail']['tmp_name'])) {
// Check IF file or thumbnail size is too big
if ($HTTP_POST_FILES['userfile']['size']>$UserFileMax_size || $HTTP_POST_FILES['Thumbnail']['size']>$ThumbnailMax_size) {
$message = "Either your Userfile File is too big or Thumbnail File is too big !";
print "<script>window.location.href='$url_this?message=$message'</script>";
exit;
}
else {}
// Set Variables to check file extension
$file_name = $_FILES['userfile']['name'];
$file_ext = strtolower(substr($file_name,strrpos($file_name,".")));
$thumbnail_name = $_FILES['Thumbnail']['name'];
$thumbnail_ext = strtolower(substr($thumbnail_name,strrpos($thumbnail_name,".")));
// Check IF file and thumbnail has extension
if (in_array($file_ext, $FILE_EXTS) && in_array($thumbnail_ext, $THUMBNAIL_EXTS)) {
// Check IF file or thumbnail already exsists
if (file_exists($UserfilePath . $HTTP_POST_FILES['userfile']['name']) || file_exists($ThumbnailPath . $HTTP_POST_FILES['Thumbnail']['name'])) {
$message = "Please rename either the User File or Thumbnail file as they already exist";
print "<script>window.location.href='$url_this?message=$message'</script>";
exit;
}
else {}
// Upload Files
$UploadFiles = copy($HTTP_POST_FILES['userfile']['tmp_name'], $UserFilePath .$HTTP_POST_FILES['userfile']['name']) &&
copy($HTTP_POST_FILES['Thumbnail']['tmp_name'], $ThumbnailPath .$HTTP_POST_FILES['Thumbnail']['name']);
// IF file and thumbnail didnt upload display message
if (!$UploadFiles) {
$message = "Upload Didn't work, please try again";
print "<script>window.location.href='$url_this?message=$message'</script>";
exit;
}
// IF file and thumbnail did upload display message
else {
$message = "Upload Succesful";
print "<script>window.location.href='$url_this?message=$message'</script>";
}
// Create Download link for file
$UniLoadDownloadLink = '<a href="' . $UserFilePath.$HTTP_POST_FILES['userfile']['name'] . '">Download</a>';
// Create IMG tag for file
$Thumbnail = "<img width=120 height=120
alt=" . 'File--' . $HTTP_POST_FILES['userfile']['name'] . '--Size--'
. $HTTP_POST_FILES['userfile']['size'] . '--Bytes' . "
src=\"".$ThumbnailPath.$HTTP_POST_FILES['Thumbnail']['name']."\">";
}
// IF file or thumbnail is wrong type then display message
else {
$message = "Sorry, either User File or Thumbnail is not the correct type.";
print "<script>window.location.href='$url_this?message=$message'</script>";
exit;
}
}
else {}
// Combined Validation end -----------------------------------------
it messes up at times when theres the wrong type of file it each field, it will still carry on to submit the rest of the data in the form (which isnt shown). i dont understand how this happens when i have the exit; code there.
can anyone see a blatent mistake in my coding?
many thanks.