1

.I have the following codes for uploading an image into a server directory, what i want to do is to resize the image before uploading. is this possible? Any help will be much appreciated. Thanks in advance!

if ((($image["type"] == "image/gif")
|| ($image["type"] == "image/jpeg")
|| ($image["type"] == "image/pjpeg")
||($image["type"] == "image/png")))
{
if ($image["error"] > 0)
{
echo "Return Code: " . $image["error"] . "<br />";
}
else
{
echo $studentno;
echo "Upload: " . $image["name"] . "<br />";
echo "Type: " . $image["type"] . "<br />";
echo "Size: " . ($image["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $image["tmp_name"] . "<br />";
$newname = time().$image["name"];
  move_uploaded_file($image["tmp_name"],"$dir" . $newname);
  echo "Stored in: " . "$dir" . $newname;
else
{
    echo '<form method="post" id="display" action="Edit.php">';
    echo '<input type="button" VALUE="Error" onClick="alert(Welcome to the Groan Zone!)">';
    echo '</form>';
}
zerey
  • 871
  • 11
  • 19
  • 37

2 Answers2

0

You need to have some code on the client side to do the image resizing for you. Take a look at Plupload based on this discussion.

Community
  • 1
  • 1
Brian Lyttle
  • 14,558
  • 15
  • 68
  • 104
0

... have a look at jCrop plugin for jQuery. The download contains a php script to deal with it. Imho it would be decent place to start. Client side provides some cropping and sizing information for the server side. Or just google php and image resizing. There should be a lot of samples and tutorials on that.

vector
  • 7,334
  • 8
  • 52
  • 80