Upload file is working fine with file size less than 2.9 MB but my phpinfo (localhost) showing upload_max_filesize 64M.
When trying to upload larger files, after form submit $_POST is empty and no file where uploaded.
here is my code:
<?php
function fileUpload($attachment){
$target_file = UPLOADDIR.basename($attachment["name"]);
if (file_exists($target_file)) {
return "Sorry, file already exists.";
}
if (move_uploaded_file($attachment["tmp_name"], $target_file)) {
return "The file ". basename( $attachment["name"]). " has been uploaded.";
} else {
return $attachment;
return "Sorry, there was an error uploading your file.";
}
}
if(isset($_POST["submit"])) {
fileUpload($_FILES['fileToUpload'])
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>