...

View Full Version : Help with php script



sorabh.v6
10-17-2012, 06:00 PM
Hi, I wrote a php script to upload docx, doc , pdf file to the server in abc folder and i want that file to be renamed with the name of uploader with uploading date as prefix. When i run it , it shows me error in line 13 and 14.Please help me . Thanks in advance.


<?php
define("UPLOAD_DIR", "C:\wamp\www\abc\""); ///home/mgcons/my_file_uploads
$name=$_POST["name"];
if(!empty($_FILES["uploaded_file"] )){
$myFile=$_FILES["uploaded_file"];
if ($myFile["error"] !== UPLOAD_ERR_OK){
echo "<p>An error occurred.</p>";
exit;
}
$day=mktime(date("m"),date("d")+1,date("Y"));
$ab=date("d m Y",$day);
$bc=$ab.$name;
$file_name=preg_replace($myFile["name"],$bc,$myFile["name"]);
$success=move_uploaded_file($myFile["tmp_name"],UPLOAD_DIR.$file_name);
if(!$success)
{
echo "Unable to save file.";
exit;
}
chmod(UPLOAD_DIR . $file_name, 644);
}
$mime="application/pdf; charset=binary"."application/vnd.openxmlformats-officedocument.wordprocessingml.document"."application/vnd.ms-word.document.macroEnabled.12"."application/vnd.openxmlformats-officedocument.wordprocessingml.template"."application/vnd.ms-word.template.macroEnabled.12"."application/msword";
exec("file -bi " . $_FILES["$myFile"]["tmp_name"], $out);
if($out[0] != $mime){
echo "File is not supported";
}
exec("clamscan --stdout ". $_FILES["$myFile"]["tmp_name"], $out, $return);
if ($return){
echo "This file is infected";
}
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum