Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


Someone wanna donate a php script to me? :) filter_list
Author
Message
Someone wanna donate a php script to me? :) #1
I am in need of a php script which allows only uploading of PNG images with a max size of 1048576 bytes. I really suck at php and if I am to make it there would be several exploits. It would be awesome if someone could whip this up real fast!

Reply

RE: Someone wanna donate a php script to me? :) #2
Quote: <?php

if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size =$_FILES['image']['size'];
$file_tmp =$_FILES['image']['tmp_name'];
$file_type=$_FILES['image']['type'];
$file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));

$expensions= array("png");
if(in_array($file_ext,$expensions)=== false){
$errors[]="extension not allowed, please choose PNG file.";
}
if($file_size > 1048576){
$errors[]='File size too high';
}
if(empty($errors)==true){
move_uploaded_file($file_tmp,"images/".$file_name);
echo "Success";
}else{
print_r($errors);
}
}
?>

<form action="" method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit"/>
</form>

Reply

RE: Someone wanna donate a php script to me? :) #3
The code above seems to fit your needs.

Reply







Users browsing this thread: 3 Guest(s)