- Edited
(Added [code]...[/code]
tags ~ MOD)
Hello,
I wondered if anybody could help by editing my code for image upload.
current issues:
image rotating,
creating blank folders when image is not uploaded
image filesize too big (i would like to resize at point of upload).
thanks.
if(isset($_POST['Submit']))
{
// Create directory if it does not exist
if(!is_dir("uploads/$location/$filedirn")) {
mkdir("uploads/$location");
mkdir("uploads/$location/$filedirn");
}
$image=$_FILES['image']['name'];
if ($image)
{
$filename = stripslashes($_FILES['image']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{
echo '<h1>Unknown fileex.!</h1>';
$errors=1;
}
else
{
$size=filesize($_FILES['image']['tmp_name']);
if ($size > 'MAX_SIZE'*1024)
{
echo '<h1>The image is too big!</h1>';
$errors=1;
}
$image_name=time().'.'.$extension;
$newname="uploads/$location/$filedirn/".$image_name;
$copied = copy($_FILES['image']['tmp_name'], $newname);
if (!$copied)
{
echo '<h1>Could not upload!</h1>';
$errors=1;
}}}}
if(isset($_POST['Submit']) && !$errors)
{
echo "<h1>Image is uploaded!</h1>";
}