rameses Posted December 23, 2009 Share Posted December 23, 2009 I have the following code that ask users to enter the information with an attachment: $fp = fopen($strresume, "rb"); $file = fread($fp, $strresume_size); $file = chunk_split(base64_encode($file)); $num = md5(time()); //Normal headers $headers = "From: Name<[email protected]>\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed; "; $headers .= "boundary=".$num."\r\n"; $headers .= "--$num\r\n"; // This two steps to help avoid spam $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; // With message $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; $headers .= "Content-Transfer-Encoding: 8bit\r\n"; $headers .= "".$message."\n"; $headers .= "--".$num."\n"; // Attachment headers $headers .= "Content-Type:".$strresume_type." "; $headers .= "name=\"".$strresume_name."\"r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; "; $headers .= "filename=\"".$strresume_name."\"\r\n\n"; $headers .= "".$file."\r\n"; $headers .= "--".$num."--"; // SEND MAIL @mail($to, $subject, $message, $headers); fclose($fp); When try to send the information, it gives the following error message: Warning: fread(): supplied argument is not a valid stream resource in /var/www/name/name.php on line 102 Warning: fclose(): supplied argument is not a valid stream resource in /var/www/name/name.php on line 144 Link to comment https://forums.phpfreaks.com/topic/186188-php-form-with-attachment/ Share on other sites More sharing options...
trq Posted December 23, 2009 Share Posted December 23, 2009 You have failed to open the file. What does $strresume contain? Link to comment https://forums.phpfreaks.com/topic/186188-php-form-with-attachment/#findComment-983341 Share on other sites More sharing options...
trq Posted December 23, 2009 Share Posted December 23, 2009 oops Link to comment https://forums.phpfreaks.com/topic/186188-php-form-with-attachment/#findComment-983342 Share on other sites More sharing options...
rameses Posted December 24, 2009 Author Share Posted December 24, 2009 Thanks for your response. ($strresume) It's the attachment. User can attach .doc/.zip files. It works on one server and it won't work on another for some reason. I have configured the php.ini file already. What's missing? Link to comment https://forums.phpfreaks.com/topic/186188-php-form-with-attachment/#findComment-983376 Share on other sites More sharing options...
trq Posted December 24, 2009 Share Posted December 24, 2009 I know what $strresume is meant to contain but what does it actually contain? Is the file path valid? The next thing is are your permissions on the file correct? Place this at the top of your script to see what errors are produced. error_reporting(E_ALL) ; ini_set('display_errors', 1); Link to comment https://forums.phpfreaks.com/topic/186188-php-form-with-attachment/#findComment-983380 Share on other sites More sharing options...
rameses Posted December 24, 2009 Author Share Posted December 24, 2009 That gave the following message: Notice: Undefined variable: strresume in /var/www/iims/akf.php on line 101 Notice: Undefined variable: strresume_size in /var/www/iims/akf.php on line 102 Warning: fread(): supplied argument is not a valid stream resource in /var/www/iims/akf.php on line 102 Notice: Undefined variable: now in /var/www/iims/akf.php on line 117 Notice: Undefined variable: strresume_type in /var/www/iims/akf.php on line 129 Notice: Undefined variable: strresume_name in /var/www/iims/akf.php on line 130 Notice: Undefined variable: strresume_name in /var/www/iims/akf.php on line 133 Warning: fclose(): supplied argument is not a valid stream resource in /var/www/iims/akf.php on line 144 I'm attaching both index.txt and name.php files for better understand. Thanks for your help Thorpe. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/186188-php-form-with-attachment/#findComment-983396 Share on other sites More sharing options...
trq Posted December 24, 2009 Share Posted December 24, 2009 There you go, you might want to actually define those variables somewhere. Link to comment https://forums.phpfreaks.com/topic/186188-php-form-with-attachment/#findComment-983397 Share on other sites More sharing options...
rameses Posted December 24, 2009 Author Share Posted December 24, 2009 It works with HostGator but not with Linode VPS. Am I missing configuration somewhere? You can give it a try at http://gator1130.hostgator.com/~pyraxic/ And http://legallytech.com/name/ Link to comment https://forums.phpfreaks.com/topic/186188-php-form-with-attachment/#findComment-983405 Share on other sites More sharing options...
trq Posted December 24, 2009 Share Posted December 24, 2009 It would appear you HostGator account has register globals enabled. This is a bad idea and has been disabled in php by default since 2002 sometime. I haven't looked at your code but form variables don't magically show up any more. If your using the post method, the data you are seeking will be within the $_POST array (the get method uses $_GET). Link to comment https://forums.phpfreaks.com/topic/186188-php-form-with-attachment/#findComment-983413 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.