Help with my upload form

Hi Everybody,

I am working on upload form for my projet and i would like to have some tips my upload scrip:

Here is what i want to achieve:

  • how to make sure the file upload is image

  • if the file upload is more than max file size, how can i use php to resize the file to my max file size allow

Here my start script:

$maxFileSize = 51200;

$fileRecipient=“C:/Upload-test/”;

if (isset($_POST[“submit”])) {

if ($_FILES[“image”][“size”] > $maxFileSize) {

$error = “File size not allowed”;

include’error.php’;
}

$moveFiche= move_uploaded_file($_FILES[‘image’][‘tmp_name’],

               $fileRecipient.$_FILES['image']['name']
);	

if($moveFiche== true) {

$success=“File been moved”;
include’success.php’;

}
else {

$error=“No file move”;

include’error.php’;

}

}

?>

PHP upload test

Select file:

Thanks.

You can’t reduce the size of a file and still keep it usable. Since you want code anyway, search w3schools for file upload.

Sponsor our Newsletter | Privacy Policy | Terms of Service