Earlier this file upload was working fine, but now im just making it fit better into what im needing but now it dosnt seam to want to work. Once submitting the form it goes to a blank white page, but when commenting out the image upload script the form acts as it should and it successfully submits the rest of the form data.
if(empty($_POST['username']) || empty($_FILES["accountimage"]["name"])) {
//$imagemessagebad = 'Error - Please Select An Image!';
} else {
$fileName = str_replace(' ', '-', strtolower($username)).'-accountimage.jpg';
$fileTmpLoc = $_FILES["accountimage"]["tmp_name"];
$fileType = $_FILES["accountimage"]["type"];
$fileSize = $_FILES["accountimage"]["size"];
$fileErrorMsg = $_FILES["accountimage"]["error"];
if(!$fileTmpLoc) {
$imagemessagebad = 'Error - Please Select An Image!';
exit();
} elseif(!preg_match("/.(jpg)$/i", $fileName) ) {
$imagemessagebad = 'Error - Wrong Image Type!';
echo('222');
unlink($fileTmpLoc);
exit();
} elseif($fileErrorMsg == 1) {
$imagemessagebad = 'Error Proccessing Image!';
echo('333');
exit();
}
$moveResult = move_uploaded_file($fileTmpLoc, "/xampp/htdocs/techbite/admin/accounts/$fileName");
if($moveResult != true) {
$imagemessagebad = 'Error Uploading Image!';
echo('444');
unlink($fileTmpLoc);
exit();
} else {
unlink($fileTmpLoc);
}
if($fileErrorMsg == 0) {
$imagemessagegood = 'The image '.$fileName.'-logo.jpg has been uploaded!';
} else {
$imagemessagebad = 'Error Uploading Image!';
}
}
I have printed the array of the file on the white blank page it generates after submitting the form and here is the info it gives of any jpg i upload:
Array ( [name] => uploadtest.jpg [type] => [tmp_name] => [error] => 1 [size] => 0 )
As you can see not all the info is there and error = 1
The upload script also gets stuck straight onto the 'if(!$fileTmpLoc) {' part.
Anyone know whats happening?