Hello Everyone! I have a PHP script that takes a form input, including a file upload, places the file on the server , emails the text input, and includes a link in the email to the uploaded file. I think the problem might lye in finding the right document root to enter into my php script. I've tried it on another server and have had success. So, when I use "echo $_SERVER["DOCUMENT_ROOT"];" on this server, I get a "Failed loading C:\Program Files\Zend\Optimizer\lib\ZendExtensionManager.dll". I cant figure out what the document root for this folder is! Any ideas on either how I can find the doc root or just plain fix this issue? Thanks! Mike <?php //settings used by the upload procedure $settings['directory_name'] = date('M-d-Y', time()); //folder name in which the form output + uploaded file will be saved $settings['form_file_name'] = date('M-d-Y_H,i', time()); //file name in which the form output will be saved $settings['upload_path'] = '/Domains/imediaavm.com/wwwroot/form_technical_files/' . $settings['directory_name']; //upload path (note: form_technical_files needs to be chmoded to 777) $settings['file_http_link'] = 'http://www.imediaavm.com/form_technical_files/'.$settings['directory_name']; //http path to uploaded files $settings['file_max_size'] = 10000; // kb $settings['file_allowed'] = array('text/plain', 'image/jpeg', 'image/pjpeg','image/gif', 'image/x-png', 'image/png', 'application/rtf', 'application/x-rtf', 'text/rtf', 'text/richtext', 'application/msword', 'application/doc', 'application/x-soffice'); $settings['language'][1] = 'Error occured during file upload'; $settings['language'][2] = 'Invalid file specified - <em>{file_type}</em>'; $settings['language'][3] = 'The size of the file (<em>{file_size} kb</em>), set for upload it\'s over the maximum allowable file size which is {file_max_size} kb.'; $settings['language'][4] = 'Cannot move file to {upload_path}'; //create directory createDirectory(); //form variables $name = $_POST['name']; $email = $_POST['email']; $workstation = $_POST['workstation']; $equipment = $_POST['equipment']; $application = $_POST['application']; $gdescription = $_POST['gdescription']; $ddescription = $_POST['ddescription']; $issue = $_POST['issue']; $troubleshooting = $_POST['troubleshooting']; $userfile = isset($_FILES['file']) ? $_FILES['file'] : NULL; $EmailTo = "shallow2040@yahoo.com"; $Subject = "Tech Support Form: $gdescription on $workstation"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'From: ' . $name . '<' . $email . '>' . "\r\n"; $headers .= "CC: shallow2040@yahoo.com" . "\r\n"; //$headers .= 'Content-Type:'. $userfile['type'].' name= '.$userfile['name'] ."\r\n"; //$headers .= 'Content-Transfer-Encoding: base64'."\r\n"; //$headers .= 'Content-Disposition: attachment; filename="'.$userfile['name'].'"'."\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $Body = ' <html> <head> </head> <body> <p><b>Workstation: </b>' . $workstation . '</p> <p><b>Equipment: </b>' . $equipment . '</p> <p><b>Application: </b>' . $application . '</p> <p><b>General Description: </b>' . $gdescription . '</p> <p><b>Specifics: </b>' . $ddescription . '</p> <p><b>Issue: </b>' . $issue . '</p> <p><b>Troubleshooting: </b>' . $troubleshooting . '</p> <p><b>Specifics: </b>' . $troubleshooting . '</p> '; //when upload file exist if ($userfile['tmp_name']) { //upload file $upload_result = uploadFile($userfile); //update email body $pos = strpos($upload_result, 'ERROR:'); if ($pos === false) { //body content for when upload procedure failed $Body .= '<p><b>Uploaded File: </b><a href="'.$settings['file_http_link'].'/'.$upload_result.'">'.$settings['file_http_link'].'/'.$upload_result.'</a></p>'; } else { //body content for when upload procedure was succesfull $Body .= '<p><b>Uploaded File: File didn\'t upload, the following error occured: <br /><em>'.str_replace('ERROR:', NULL, $upload_result).'</em></p>'; } } $Body .= ' </body> </html>'; //save form output to file saveFormOutput($Body); $success = mail($EmailTo, $Subject, $Body, $headers); $EmailTo = $email; $Subject = "IT Information Recieved: $gdescription on $workstation"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: iMedia Tech Support <it@imediaavm.com>' . "\r\n"; $Body = ' <html> <head> </head> <body> <p>Hello,</p> <p>Thanks for reporting this issue, your email has been delivered to our IT staff. We will try to resolve this issue as quickly as possible, if any additional information becomes available in the future, please reply directly to this email. This will help us to organize the timeline of the issue. Here is an overview of the information you sent us:<br /></p> <p><b>Workstation: </b>' . $workstation . '</p> <p><b>Equipment: </b>' . $equipment . '</p> <p><b>Application: </b>' . $application . '</p> <p><b>General Description: </b>' . $gdescription . '</p> <p><b>Specifics: </b>' . $ddescription . '</p> <p><b>Issue: </b>' . $issue . '</p> <p><b>Troubleshooting: </b>' . $troubleshooting . '</p> <p><b>Specifics: </b>' . $troubleshooting . '<br /></p> <p>Thank You,</p> <p>iMedia Support Staff</p> </body> </html>'; $success = mail($EmailTo, $Subject, $Body, $headers); //upload file function function uploadFile($userfile) { global $settings; //get file details $file_name = $userfile['name']; $file_type = $userfile['type']; $tmp_name = $userfile['tmp_name']; $error = $userfile['error']; $file_size = $userfile['size']; //show errror if ($error) { return 'ERROR:'. $settings['language'][1]; } //get original file name & file extension list($file_name, $file_ext) = fileDetails($file_name); //file_name $file_name = safeName($file_name).$file_ext; //file path $file_path = $settings['upload_path'].'/'.$file_name; //check file type if (!in_array($file_type, $settings['file_allowed'])) { return 'ERROR:'. str_replace('{file_type}', $file_type, $settings['language'][2]); } //check file size if ($file_size / 1000 > $settings['file_max_size']) { return 'ERROR:'. str_replace('{file_size}', $settings['file_max_size'], $settings['language'][3]); } //check if file exist if(file_exists($file_path)) { return 'ERROR:'. $settings['language'][4]; //file already exist } //upload file if (!@move_uploaded_file($tmp_name, $file_path)) { return 'ERROR:'. str_replace('{upload_path}', $settings['upload_path'], $settings['language'][4]); //cannot move file } //return result return $file_name; } //get file name & extension function fileDetails($file) { $file_array = explode('.', $file); $file_ext = count($file_array) > 1 ? '.'.array_pop($file_array) : NULL; $file_name = implode('.', $file_array); return array($file_name, $file_ext); } //safe name function safeName($string) { $string = str_replace(' - ', ' ', $string); $string = preg_replace('/[^-a-z\d\s]+/s', '', strtolower($string)); $string = preg_replace("/[{-}\s]+/", '-', trim($string)); return $string; } //create directory function createDirectory($chmod = 0777) { global $settings; //prepare variables $directory_path = $settings['upload_path']; //check if directory already exist if (!file_exists($directory_path)) { //create directory mkdir($directory_path, $chmod); } return NULL; } //save form output function saveFormOutput($content) { global $settings; //prepare variables $file_name = $settings['upload_path'].'/'.$settings['form_file_name'].'.html'; //save output $fp = fopen($file_name, 'w'); fwrite($fp, $content); fclose($fp); } ?> Code (markup):
Perhaps, try asking your host to make sure ZendExtensionManager.dll is enabled via php.ini and exists in the correct directory.
Thanks for the help everyone. The hosting company updated their PHP to version 5.2.9 (from v4) - this resolved the issue I was having.