i got code in php with upload file from cms form and send to email as attachment the code wht i have is
".$file."";
$filelist .= " x";
}
}
function do_upload($upload_dir, $upload_url) {
$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_name = str_replace("\\","",$file_name);
$file_name = str_replace("'","",$file_name);
$file_type = $_FILES['userfile']['type'];
$file_size = $_FILES['userfile']['size'];
$result = $_FILES['userfile']['error'];
$file_url = $upload_url.$file_name;
$file_path = $upload_dir.$file_name;
//File Name Check
if ( $file_name =="") {
$message = "Invalid File Name Specified";
return $message;
}
//File Size Check
else if ( $file_size > 2000000) {
// print $file_size;
// $message = "The file size is over 1MB.";
// return $message;
}
//File Type Check -- Prevent possible attacks
else if ( strpos($file_name,".php") !== false
|| strpos($file_name,".cgi") !== false
|| strpos($file_name,".htm") !== false
|| strpos($file_name,".phtm") !== false )
return;
else if ( strpos($file_type,"image") !== false
|| $file_type == "application/msword");
else {
//$message = "Sorry, demo. only allows image or ms-word upload." ;
//$message .= "You may allow other types(i.e, .zip) on your own server." ;
//return $message;
}
$result = move_uploaded_file($temp_name, $file_path);
if (!chmod($file_path,0755))
$message = "change permission to 755 failed.";
else
$msgban = ($result)?"$file_name" :
$message = ($result)?"$file_name uploaded successfully. In cel mult 24 ore Bannerul va aparea pe site." :
"Somthing is wrong with uploading a file.";
return $message;
}
?>
\r\n";
$headers .= "Reply-To: " . $_POST["email"];
$content = "Name : " . $_POST["name"] . "\n";
$content .= "Email Address : " . $_POST["email"] . "\n";
$content .= "Comments : " . $_POST["website"] . "\n";
$content .= "Comments : " . $_POST["website"] . "\n";
mail($sendTo, $subject, $content, $headers);
?>
the code works fine with standalone form but when used from cmsmadesimple it doesnot can someone pls help me find wht i m doing wrong right now i m not bothered abt attachment but prblem is the file is not getting uploaded on server
php file upload issue with cms
php file upload issue with cms
Last edited by ankitm on Mon Jan 14, 2008 11:20 pm, edited 1 time in total.
Re: php file upload issue with cms
Have you tried the Uploads module instead? it lets frontend users upload files themselves. Also check out Form Builder if you wanna send email, these are both pretty neat modules, very useful and you don't have to re-invent the wheel.
Re: php file upload issue with cms
thanks a lot of information i just installed the upload module and cmsmailer now trying to figure out way to use them in my custom form if u can help with tht........thanks
Re: php file upload issue with cms
Code: Select all
{cms_module module='FormBuilder' form='contact'}
Last edited by hexdj on Tue Jan 15, 2008 9:36 am, edited 1 time in total.