wap3
04-30-2003, 05:09 PM
Hi guys
I found a script whilst searching here for uploading an image.
I have modified the script abit to try and get it to work for my situation.
The script doesn't generate any errors and reaches it's destination so to speak, where it says "your submission has been . . "
And along the way it also echos out the statements I put in there for testing purposes, so I know it has picked up the post variables and has the right path to the image. But it just doesn't save the image to the folder named 'Images'.
Any ideas why ??
function check_image($HTTP_POST_VARS) {
echo "$HTTP_POST_VARS[image]";
$upload_error = '';
if(isset($HTTP_POST_VARS['image']['tmp_name']) && $HTTP_POST_VARS['image']['tmp_name'] !== "none")
{
$f_type = getimagesize($HTTP_POST_VARS['image']);
foreach($f_type as $key) {
echo "$key"; }
if($f_type[2] > 0)
{
// ftype[2] returns the filetype - where a valid image is always above zero
// you could type test further - maybe !== 2 ~ not jpeg or somesuch.
if($HTTP_POST_VARS['image']['size'] < 116000)
{
// check image size in bytes
$name = $HTTP_POST_VARS['image']['name'];
$upfile = "../Images/".$name;
copy($HTTP_POST_VARS['image'], $upfile);
echo 'Your submission has been saved and our administrator will check it shortly, thankyou.<br /><br />';
}
else
{
echo "The file you uploaded was not below 116kb.";
}
}
else
{
echo "The file you uploaded was not a valid image file.";
}
}
}
:thumbsup:
I found a script whilst searching here for uploading an image.
I have modified the script abit to try and get it to work for my situation.
The script doesn't generate any errors and reaches it's destination so to speak, where it says "your submission has been . . "
And along the way it also echos out the statements I put in there for testing purposes, so I know it has picked up the post variables and has the right path to the image. But it just doesn't save the image to the folder named 'Images'.
Any ideas why ??
function check_image($HTTP_POST_VARS) {
echo "$HTTP_POST_VARS[image]";
$upload_error = '';
if(isset($HTTP_POST_VARS['image']['tmp_name']) && $HTTP_POST_VARS['image']['tmp_name'] !== "none")
{
$f_type = getimagesize($HTTP_POST_VARS['image']);
foreach($f_type as $key) {
echo "$key"; }
if($f_type[2] > 0)
{
// ftype[2] returns the filetype - where a valid image is always above zero
// you could type test further - maybe !== 2 ~ not jpeg or somesuch.
if($HTTP_POST_VARS['image']['size'] < 116000)
{
// check image size in bytes
$name = $HTTP_POST_VARS['image']['name'];
$upfile = "../Images/".$name;
copy($HTTP_POST_VARS['image'], $upfile);
echo 'Your submission has been saved and our administrator will check it shortly, thankyou.<br /><br />';
}
else
{
echo "The file you uploaded was not below 116kb.";
}
}
else
{
echo "The file you uploaded was not a valid image file.";
}
}
}
:thumbsup: