Jump to content

Need to make photo upload code autoresize photos If you can help please reply


Recommended Posts

I have a photo upload page on my website

 

the members are having alot of trouble uploading photos because it only excepts w800*h600

 

and alot of people cant resize the photos... how can I have this code instead of displaying photo is too large

 

display photo being resized and resize it automaticly??

 

I have seen some resizing code out there but is it only for jpeg? or can it also do gif??

 

here is the code I have

 

if($filename_1 != "")

{

check_files_array();

$number = -1;

                for ($i = 1; $i <= $max_photos_uploaded; $i++)

                {

                $f = "filename_$i";

                if ($fPhoto[$f] == "" && $number < 1)

                    {

                        $number = $i;

                    }

                }

                $size = @GetImageSize ($_FILES["filename_1"]["tmp_name"]);

                if ($_FILES["filename_1"]["size"] > $max_image_size * 1024)

                {

                        $errors_string .= "The file you have uploaded is too large. Please limit your uploads to" .' '. $max_image_size."KB.";

                        $errors_num++;

                }

                else if ($number < 1)

                {

                        $errors_string .= "You cannot upload any more photos.";

                        $errors_num++;

                }

                else if ($size[0] > $max_image_width)

                {

                        $errors_string .= "The file you have uploaded is too large. Please limit your image width to" .' '. $max_image_width." pixels.";

                        $errors_num++;

                }

                else if ($size[1] > $max_image_height)

                {

                        $errors_string .= "The file you have uploaded is too large. Please limit your image height to" .' '. $max_image_height." pixels.";

                        $errors_num++;

                }

                else

                {

if(man_MIME2Ext($_FILES["filename_1"]['type']) != "")

{

$file_source = $member_code."_$number.".man_MIME2Ext($_FILES["filename_1"]['type']);

upload_file($_FILES["filename_1"]['tmp_name'], "photos/$file_source", man_MIME2Ext($_FILES["filename_1"]['type']));

 

if($fPhoto["id"] == "")

q("INSERT INTO dt_photos (filename_$number, member_id, description_$number) VALUES('$file_source', '$fMember[id]', '$description')");

else

{

q("UPDATE dt_photos SET filename_$number='$file_source' WHERE member_id='$fMember[id]'");

q("UPDATE dt_photos SET description_$number='$description' WHERE member_id='$fMember[id]'");

}

                  if ($autoapprove == "on")

q("UPDATE dt_profile SET status='1' WHERE member_id='$fMember[id]'");

                  else

                    q("UPDATE dt_profile SET status='3' WHERE member_id='$fMember[id]'");

                   

                  $login = $fMember[ login ];

                  if(nr(q("SELECT member_id FROM dt_profile WHERE member_id='$fMember[id]' LIMIT 1")))

            {

            mailSend($admin_mail, "admin_profile_complete.html");

            }

}

            else

            {

              $errors_string .= "Please only upload GIF or JPEG image files.";

              $errors_num++;

            }

          }

}

 

 

 

 

 

 

 

 

 

 

this is not the entire code... but is the part where the upload is done......

 

please help me out or give me a suggestion...

 

thanks

 

Paul

        }

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.