Hi All,
Always use this code for image upload to prevent images with vulnerable scripts.
<?php
$newIm = @imagecreatefromjpeg($_FILES["image"]["tmp_name"]);
if (!$newIm) {
// gd could not create an image from the source
// most likely, the file was not a valid jpeg image
header('location:userhome.php?msg=error'); // Code to direct to your home page showing error
}
else // code to upload file
move_uploaded_file($_FILES["image"]["tmp_name"], $target_file) or die('Error'.mysql_error());
?>
Always use this code for image upload to prevent images with vulnerable scripts.
<?php
$newIm = @imagecreatefromjpeg($_FILES["image"]["tmp_name"]);
if (!$newIm) {
// gd could not create an image from the source
// most likely, the file was not a valid jpeg image
header('location:userhome.php?msg=error'); // Code to direct to your home page showing error
}
else // code to upload file
move_uploaded_file($_FILES["image"]["tmp_name"], $target_file) or die('Error'.mysql_error());
?>
No comments:
Post a Comment