File upload
Posted: Mon Jun 09, 2008 10:29 am
hey guys,
i was wondering if anyone can help me with this:
Every time i try to upload a file i get Error: A problem occurred during file upload!
Now the funny thing is... it works fine locally on my Windows XP machine but when i try to run it on a Linux machine it gives me the error message.
And one more thing:
I'm planning on having this run on a subdomain. Is it possible to have the files uploaded into a /img/ folder on the main domain name???
Thanks for your time guys and hope someone is willing to shed some light for me...
i was wondering if anyone can help me with this:
Code: Select all
<?php
$err = 24;
if ($err!=24) echo 'something';
elseif ($_FILES['file']['error'] == 0) {
$filename = basename($_FILES['file']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
$type=$_FILES["file"]["type"];
$size=$_FILES["file"]["size"];
$ok=1;
$info = getimagesize($_FILES['file']['tmp_name']);
//echo $info[0].' '.$info[1];
// echo $type;
if (!(($ext=="jpg") || ($ext=="gif")))
{$ok=0;
$err=1;
}
elseif (!(($type=="image/pjpeg") || ($type=="image/gif")))
{ $ok=0;
$err=2;
}
elseif ($size > 200000)
{$ok=0;
$err=3;
}
elseif (($info[0]!=800) || ($info[1]!=600))
{$ok=0;
$err=4;
};
if ($ok==1)
{
if ((move_uploaded_file($_FILES['file']['tmp_name'] , "/img/" . $_FILES["file"]["name"]))) {
echo "File saved";
}
else { echo "Error: A problem occurred during file upload!"; }
}
else { header('Location: add_file.php?err='.$err);
}
}
?>
Now the funny thing is... it works fine locally on my Windows XP machine but when i try to run it on a Linux machine it gives me the error message.
And one more thing:
I'm planning on having this run on a subdomain. Is it possible to have the files uploaded into a /img/ folder on the main domain name???
Thanks for your time guys and hope someone is willing to shed some light for me...