[imp] Attachments fail, uploads don't (was: All but attachmen ts)

Joost De Cock Joost.DeCock@astrid.be
Wed, 12 Jun 2002 15:49:00 +0200


ok, so I dived into the source code,

I changed the 2 identical error mesages in ADD_ATTACHMENT case in
compose.php so I can differentiate between them.

I have a problem with this if statement:

if (!isset($HTTP_POST_FILES['file_upload']['size']) ||
        !isset($HTTP_POST_FILES['file_upload']['tmp_name']) ||
        !is_uploaded_file($HTTP_POST_FILES['file_upload']['tmp_name'])){

It gets triggered so I receive a "there was a problem blablabla...

I copied the code to a test script (code is messy

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">

<form enctype="multipart/form-data" action="upload.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
  Send this file: 
  <input name="file_upload" tabindex="8" type="file" size="40" class="fixed"
/>&nbsp;
<input type="submit" value="submit">
</form>



<?php  
if ($file_upload)
{
if (!isset($HTTP_POST_FILES['file_upload']['size']) ||
        !isset($HTTP_POST_FILES['file_upload']['tmp_name']) ||
        !is_uploaded_file($HTTP_POST_FILES['file_upload']['tmp_name'])) 
	   
	   { 
	   echo "<h4>problem</h4>"; 
	   }
	   $size=$_FILES['file_upload']['size'];
	   $tmp=$_FILES['file_upload']['tmp_name'];
	   echo "uploaded: ";
	   echo
is_uploaded_file($HTTP_POST_FILES['file_upload']['tmp_name']);
	   echo "<br>size: $size <br>";
	   echo "tmp: $tmp <br><br><br><br><br> ";
print "$file_upload = file_upload <br>";
print "$file_upload_name = file_upload_name <br>";
print "$file_upload_type = file_upload_type <br>";
print "$file_upload_size = file_upload_size <br>";
print "$file_upload_tmp_name = tmp_name <br>";

echo "file: $file_upload<br>";
echo "sending...<br>";
// In PHP 4.1.0 or later, $_FILES should be used instead of
$HTTP_POST_FILES.
//if (is_uploaded_file($_FILES['file_upload']['tmp_name'])) {
//    copy($_FILES['file_upload']['tmp_name'],"/tmp");
//} else {
//    echo "Possible file upload attack. Filename: " .
$HTTP_POST_FILES['file_upload']['name'];
//}
/* ...or... */
move_uploaded_file($file_upload, "/var/www/html/after/$file_upload_name");
}
?>


</body>
</html>


As you can see, I use the exact same if statement, but it doesn't get
triggered, I see this output:

uploaded: 1
size: 382 
tmp: /tmp/phpUcVRas 

/tmp/phpUcVRas = file_upload 
prefs.sql = file_upload_name 
application/octet-stream = file_upload_type 
382 = file_upload_size 
= tmp_name 
file: /tmp/phpUcVRas
sending...

So the file is an valid uploaded file, it has a size and a temo name.
Furthermore, after the script is run, I can see the prefs.sql file that i
uploaded in the /var/www/html/after/ directory.

Any idea why there is this difference in the triggering of the if statement

Joost



-----Original Message-----
From: Jan Schneider [mailto:jan@horde.org]
Sent: woensdag 12 juni 2002 14:15
To: imp@lists.horde.org
Subject: Re: [imp] Attachments fail, uploads don't (was: All but
attachments)


Zitat von Joost De Cock <Joost.DeCock@astrid.be>:

> Hi there,
> 
> I've haven't been able to get attachments to work.
> I've been working on this for a while now, and I've checked everything
> Eric
> told me to.
> 
> I've used the example scripts on the php site to create my own little
> upload
> page, and I can upload any file (as long as it isn't too big) 
> 
> However, if I want to attach a file in IMP, I still receive that annoying
> error message.
> 
> Is there a way to see the real error message, does anybody has an idea,
> and
> where is the attachment functionality located in the source, maybe I can
> check it out.

The attachment code is in the ADD_ATTACHMENT case in compose.php.

Jan.

--
http://www.horde.org - The Horde Project
http://www.ammma.de - discover your knowledge
http://www.tip4all.de - Deine private Tippgemeinschaft

-- 
IMP mailing list
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: imp-unsubscribe@lists.horde.org



**********************************************************************
The information in this mail is confidential and is intended solely
for the addressee(s).
Access to this email by anyone else is unauthorised. If you are not
an intended recipient, you must not read, use or disseminate the 
information contained in the email.
**********************************************************************