Jump to content

uploading image


pranshu82202

Recommended Posts

Well i have a php script which i use to upload jpg or gif  images only...

 

I want that whenever user uploads an image of any resolution my script transforms it to 100*100 resolution..

 

What should i do...

 

Here is my PHP Script...

 

$_FILES["file"]["name"]=$_SESSION['id'].".jpg";
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
/*
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
*/
    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo " You have already uploaded your profile pic...";
      }
    else
      {


      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
//rename("/upload/" . $_FILES["file"]["name"], "/upload/" . $_SESSION['id'] );
$_SESSION['result']="PROFILE SETUP SUCCESSFULL";
header('location:members.php');
      }
    }
  }
else
  {
  echo "Invalid file";
  }
}

Link to comment
https://forums.phpfreaks.com/topic/246140-uploading-image/
Share on other sites

A class that is a few years old, but handles this kind of stuff with ease (especially to the user), is called SimpleImage.  I have used it in the past, and have recommended it before.  I think it might could help you do what you are trying to do.

Link to comment
https://forums.phpfreaks.com/topic/246140-uploading-image/#findComment-1264138
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.