Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-17-2012, 06:00 PM   PM User | #1
sorabh.v6
New to the CF scene

 
Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
sorabh.v6 is an unknown quantity at this point
Help with php script

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 Code:
<?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_name644);
    }
    
$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";
            }
?>
sorabh.v6 is offline   Reply With Quote
Reply

Bookmarks

Tags
file upload

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:52 PM.


Advertisement
Log in to turn off these ads.