<?php
require_once ('../index.php');
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br/>";
}
else
{
}
$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 200000) && in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br/>";
}
else
{
if (file_exists("../uploadedImages/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"../uploadedImages/" . $_FILES["file"]["name"]);
echo "Du har laddat upp en bild.";
}
}
}
else
{
echo "Invalid file";
}
I wanna be able to resize my image, when i upload my image.
The code that I have now Im uploading a image to my uploadedImages folder, and I want to resize my images to small thumbs.
This script resize an Image into two 60px and 25px. Take a look at $newwidth you have to modify size values.
Finds file extensions.