Hello there, I need some advice with the following script.
I use this script to ad pictures to member profiles on a datingsite.
They can place 2 images with every profile.
Most people stick with the rules on my site, but some of them are uploading pictures from let's say 200 - 500 kb.
Since i run a free site, i'm not happy with the way my diskspace get's filled.
Can i add a max file upload to this(30kb) and also an error when someone tries to upload more.
Most important is how will i do this
<?
function upload_file($in, $out)
{
move_uploaded_file($in,$out);
}
function man_MIME2Ext($mime)
{
switch($mime)
{
case "image/gif" :
return "gif";
case "image/pjpeg" :
return "jpg";
case "image/jpeg" :
return "jpg";
}
return "";
}
$rPhotos = q("SELECT id FROM dt_photos WHERE member_id='$fMember[id]'");
if($filename_1 != "" || $filename_2 != "")
{
$number = 1;
if($filename_2 != "")
{
$number = 2;
}
if(man_MIME2Ext($HTTP_POST_FILES["filename_$number"]['type']) != "")
{
$file_source = $member_code."_$number.".man_MIME2Ext($HTTP_POST_FILES["filename_$number"]['type']);
upload_file($HTTP_POST_FILES["filename_$number"]['tmp_name'], "photos/$file_source");
if(e($rPhotos))
{
q("INSERT INTO dt_photos (filename_$number, member_id) VALUES('$file_source', '$fMember[id]')");
}
else
{
q("UPDATE dt_photos SET filename_$number='$file_source' WHERE member_id='$fMember[id]'");
}
q("UPDATE dt_profile SET status='3' WHERE member_id='$fMember[id]'");
}
}
$fPhoto = f(q("SELECT filename_1, filename_2 FROM dt_photos WHERE member_id='$fMember[id]'"));
include "templates/upload_photo.ihtml";
?>
:p