fagnonk Posted July 22, 2009 Share Posted July 22, 2009 I have a php script that looks like this: <?php $max_allowed_file_size = "1000"; // this is size in KB list($name_of_uploaded_file, $type_of_uploaded_file, $size_of_uploaded_file) = GetUploadedFileInfo(); if(!Validate($name_of_uploaded_file, $type_of_uploaded_file, $size_of_uploaded_file, $max_allowed_file_size)) { exit(); } LoadUploadedFile($name_of_uploaded_file); $path_of_uploaded_file = "uploads/" . $name_of_uploaded_file; include_once('Mail.php'); include_once('mime.php'); ComposeMail($path_of_uploaded_file); //////////////////// Functions //////////////////////// function GetUploadedFileInfo() { $file_info[] = basename($_FILES['uploaded_file']['name']); $file_info[] = substr($file_info[0], strrpos($file_info[0], '.') + 1); $file_info[] = $_FILES["uploaded_file"]["size"]/1024; return $file_info; } function Validate($name_of_uploaded_file, $type_of_uploaded_file, $size_of_uploaded_file, $max_allowed_file_size) { if($size_of_uploaded_file>$max_allowed_file_size ) { echo "Size of file is greater than" . $max_allowed_file_size . " KB. <a href='attachment_email_form.html'>Click Here to upload a smaller sized file.</a>"; return false; } $allowed_extension = array("jpg", "jpeg", "gif", "bmp"); for($i=0; $i<sizeof($allowed_extension); $i++) { $allowed_extension[$i] = strtoupper($allowed_extension[$i]); } $type_of_uploaded_file = strtoupper($type_of_uploaded_file); if(!(in_array(strtoupper($type_of_uploaded_file),$allowed_extension))) { echo "You have uploaded a file with an extension of " . $type_of_uploaded_file . " . This type is not allowed. Please upload a file with allowed image extensions like jpg, jpeg, bmp, gif. <a href='attachment_email_form.html'>Click Here to upload a file with allowed extension.</a>"; return false; } return true; } function LoadUploadedFile($name_of_uploaded_file) { move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], "uploads/" . $name_of_uploaded_file); return true; } function ComposeMail($name_of_uploaded_file) { $name = $_POST['name']; $user_message = $_POST['message']; $to = "[email protected]"; $subject="An email with attachement is sent"; $from = "[email protected]"; $text = "A user " . $name . "has sent you this message and an attachment: " . $user_message; $message = new Mail_mime(); $message->setTXTBody($text); $message->addAttachment($name_of_uploaded_file); $body = $message->get(); $extraheaders = array("From"=>$from, "Subject"=>$subject); $headers = $message->headers($extraheaders); $mail = Mail::factory("mail"); $mail->send($to, $headers, $body); echo "Your Email with attachment was sent."; } ?> The problem is that the script seems to believe that I have pear installed here: .:/usr/local/php-5.2.6-1/share/pear when it is actually installed in: /usr/bin/pear How can redirect this script to the location of my pear installation? Link to comment https://forums.phpfreaks.com/topic/166920-defining-the-location-of-pear/ Share on other sites More sharing options...
trq Posted July 22, 2009 Share Posted July 22, 2009 Change the include_path directive within your php.ini file to include your pear directory. Link to comment https://forums.phpfreaks.com/topic/166920-defining-the-location-of-pear/#findComment-880069 Share on other sites More sharing options...
fagnonk Posted July 22, 2009 Author Share Posted July 22, 2009 Hmm, I edited my php.ini but now I am getting new errors: Warning: include_once(mime.php) [function.include-once]: failed to open stream: No such file or directory in /nfs/c02/h06/mnt/xxxx/domains/xxxxxxx.com/html/filer/send-email-form.php on line 11 Warning: include_once() [function.include]: Failed opening 'mime.php' for inclusion (include_path='.:/usr/local/php-5.2.6-1/share/pear') in /nfs/c02/h06/mnt/xxxxx/domains/xxxxxxx.com/html/filer/send-email-form.php on line 11 Fatal error: Class 'Mail_mime' not found in /nfs/c02/h06/mnt/xxxxx/domains/xxxxxx.com/html/filer/send-email-form.php on line 57 Any idea what this could mean? Link to comment https://forums.phpfreaks.com/topic/166920-defining-the-location-of-pear/#findComment-880080 Share on other sites More sharing options...
trq Posted July 22, 2009 Share Posted July 22, 2009 Did you restart the server? Your path still doesn't like any changes where made. Link to comment https://forums.phpfreaks.com/topic/166920-defining-the-location-of-pear/#findComment-880093 Share on other sites More sharing options...
fagnonk Posted July 22, 2009 Author Share Posted July 22, 2009 I added the include path and restarted the server. Is it possible that I don't have something installed? Like this mail.php? Link to comment https://forums.phpfreaks.com/topic/166920-defining-the-location-of-pear/#findComment-880116 Share on other sites More sharing options...
trq Posted July 22, 2009 Share Posted July 22, 2009 Look at your include path in the last error, it hasn't changed. Are you sure you edited the correct php.ini? Is it possible that I don't have something installed? Like this mail.php? Yeah, possible. Have you looked in the pear directory to see whats there? Link to comment https://forums.phpfreaks.com/topic/166920-defining-the-location-of-pear/#findComment-880118 Share on other sites More sharing options...
fagnonk Posted July 22, 2009 Author Share Posted July 22, 2009 OK Mail_Mime wasn't installed so I corrected that. I added the following line to my php.ini: include_path = ".:/home/xxxxx/users/.home/pear/php" I don't think there is a syntax error here, I even tried refrencing it in the actual script as such: set_include_path('/home/#####/users/.home/pear/php'); This returned different errors: Warning: require_once(PEAR.php) [function.require-once]: failed to open stream: No such file or directory in /nfs/c02/h06/mnt/xxxxx/users/.home/pear/php/Mail.php on line 21 Fatal error: require_once() [function.require]: Failed opening required 'PEAR.php' (include_path='/home/xxxxx/users/.home/pear/php') in /nfs/c02/h06/mnt/xxxx/users/.home/pear/php/Mail.php on line 21 Link to comment https://forums.phpfreaks.com/topic/166920-defining-the-location-of-pear/#findComment-880130 Share on other sites More sharing options...
trq Posted July 22, 2009 Share Posted July 22, 2009 That doesn't look like a valid place to keep pear, are you sure the second home directory is hidden (starts with a .) ? Anyways, is this directory readable by Apache? Link to comment https://forums.phpfreaks.com/topic/166920-defining-the-location-of-pear/#findComment-880139 Share on other sites More sharing options...
fagnonk Posted July 22, 2009 Author Share Posted July 22, 2009 Mediatemple has a crazy setup. That location came directly from there help docs (http://kb.mediatemple.net/questions/149/How+can+I+install+and+use+pear+modules+on+the+%28gs%29+Grid-Service%3F). I will contact mt tech support again and see if they have any information. Link to comment https://forums.phpfreaks.com/topic/166920-defining-the-location-of-pear/#findComment-880145 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.