Jump to content

Script review


allaboutthekick

Recommended Posts

I found a script on the internet and edited it a lot but i dont think i compiled it completely correctly, please review and help me fix my mistakes.

1. It wont delete images that are too big from the server and wont display the error
2. Only jpeg images are allowed but when other image types are uploaded it just causes a warning.


[code]
<?php
if (isset($_COOKIE['User'])) {
$user = $_COOKIE['User'];
setcookie('User',$user,time()+(60*60));
} else {
Echo 'Please login before posting an image';
die();
}

$Message="";
$msg="";
$file_upload="false";

if ($_FILES['userfile']['tmp_name']) {

$userfile=$_FILES['userfile']['tmp_name'];
$userfile_size=$_FILES['userfile']['size'];
$userfile_type=$_FILES['userfile']['type'];
$userfile_name=$_FILES['userfile']['name'];

$file_upload="true";
if ($userfile_size > 500000){$Message=$Message."Your uploaded file size is more than 500KB so please reduce the file size and then upload.<BR/>" ;
$file_upload="false";
}

if (!$userfile_type =="image/jpeg"){$Message=$Message."Your uploaded file must be of JPG. Other file types are not allowed<BR/>";
$file_upload="false";}


$badd = time();
$baseadd = $badd . ".jpg"; //User time stamp
$add="imgs/o".$baseadd;



if ($file_upload='true') {

if(move_uploaded_file ($userfile, $add)){
$msg = $userfile_name . " Has been uploaded";
}else{echo "Failed to upload file Contact Site admin to fix the problem";}


$out_file = "imgs/". $baseadd;
$max_width = 300;
$max_height = 300;

list($width_orig, $height_orig) = getimagesize($add);

if ($max_width && ($width_orig < $height_orig)) {
    $max_width = ($max_height / $height_orig) * $width_orig;
} else {
    $max_height = ($max_width / $width_orig) * 1;
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/26507-script-review/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.