Jump to content

[SOLVED] pic uploader script help


NSW42

Recommended Posts

Heya again to anyone that may know where ive gone wrong, for some reason now the script wont allow any pic gif jpeg to upload, if anyone can picked to see whats wrong would be appreciated..

 

<?php

include("config.php"); 

include("user_check.php");

 

$sql = mysql_query("SELECT * FROM users WHERE username = '$_COOKIE[username]'"); 

$row = mysql_fetch_array($sql); 

 

$path = "propics/"; 

$file_size_max = 30024 * 50024; 

$possible_size = round($file_size_max / 50024); 

$possible_extensions = array ('jpg', 'jpeg', 'pjpg', 'gif', 'bmp', 'png');   

$count_possible_extensions = count($possible_extensions);   

 

if (!$case) $case = 1;     

switch ($case) 

case 1:

?> 

</div><form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">

<table border="0" cellspacing="0" cellpadding="4">

<tr>

<td>

<B><font face='Tahoma' size='2' color='ffffcc'> SELECT A PICTURE FROM YOUR COMPUTER<br>TO ADD TO YOUR PROFILE.Jpg,Gif,Bmp ONLY.<br>200x200 or About 70kb max size<br>Your old picture will be deleted<br>Please make sure your picture is square <? echo $lang; ?>

<br>

<font face='Tahoma' size='2' color='#003366'><? echo $lang; ?>

<br>

<br>

<input type="file" name="plaatje" size="40">

<br>

<input type="hidden" name="case" value="2">

<input type="submit" value="<? echo UPLOAD; ?>">

<br>

</td>

</tr>

</table>

</form>

<?php

break;

 

case 2:

if(!$_FILES[plaatje]) 

{

echo 'You didn\'t select an picture.'; 

}

if($_FILES[plaatje]) 

{

$file_size = round($_FILES[plaatje] / 50024);

$file_type = $_FILES[plaatje][type];

$file = basename($_FILES[plaatje][name]);

$ext = explode(".", $file);

$file_extension = $ext[1]; 

$file_name = $ext[0];

$fileinfo = pathinfo($plaatje);

if(!in_array($fileinfo['extension'],$possible_extensions)) exit('File not allowed. Only gif, jpeg, bmp allowed.');

if(filesize($plaatje) > 85000) exit('File too big. Max size 80kb.');

if($file_size > $possible_size) echo "</div>$lang kb"; 

if (!in_array(strtolower($file_extension),$possible_extensions)) 

{   

echo "</div>$lang "; 

for ($i = 0; $i < $count_possible_extensions; $i++ ) echo "</div>";

}

else

{

$file_name = "artikel_pic";

$n = 0;   

$temp_name = $file_name;

// while (file_exists($path . $temp_name . $n . "." . $file_extension)) $n = $n + 1;

unlink($path.$file_name.'.'.$file_extension);

if(move_uploaded_file($plaatje, $path . $file_name . "." . $file_extension)) 

{

$update1 = mysql_query("UPDATE users SET pro_pic = '$baseurl$path$file_name.$file_extension' WHERE username = '$_COOKIE[username]'") or die(mysql_error());

print("Photo uploaded");

exit;

else 

echo "</div>"; 

}

}

break; 

}

?>

Link to comment
https://forums.phpfreaks.com/topic/44597-solved-pic-uploader-script-help/
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.