www.webdeveloper.com
Results 1 to 2 of 2

Thread: uploading doc files

  1. #1
    Join Date
    May 2006
    Posts
    48

    uploading doc files

    hi i am trying to make an uploads form only for doc files. what i have tried (without any results) is the following
    Code:
    if (is_uploaded_file($_FILES['userfile']['tmp_name'])){
    		if($_FILES['userfile']['type']=="application/.doc"){ 
    			$uploaddir = '../Uploads/Files/ADIP/Personnel/';
    			list($name, $extension)=split('[.]',$_FILES['userfile']['name']);
    			$filename="_ADIP".".".$extension;
    			$uploaded_file=$result["l_name_en"].$result["id"].$filename;
    			ftp_upload($_FILES['userfile']['tmp_name'],$uploaded_file,"Personnel/");
    			move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir.$uploaded_file);
    			chmod($uploaddir.$uploaded_file, 0777);
    			}
    		else
    			header("location:census.php?import=personnel&notice=4");
        }
    Any ideas how to do this?
    Thx in advance

  2. #2
    Join Date
    Apr 2007
    Posts
    1,664
    try making $uploaddir an absolute path to be sure it's going where you think it should.

    $uploaded_file=$result["l_name_en"].$result["id"].$filename;
    Where is $result coming from? Are you sure those vars exist at this point?

    what is ftp_upload() and is it working correctly?

    You can start debugging this by removing all extraneous code and building it up until you find the problem.

    PHP Code:
    if (is_uploaded_file($_FILES['userfile']['tmp_name'])){
            if(
    $_FILES['userfile']['type']=="application/.doc"){ 
                
    $uploaddir '../Uploads/Files/ADIP/Personnel/';//make absolute to test
                
                //list($name, $extension)=split('[.]',$_FILES['userfile']['name']);
                //$filename="_ADIP".".".$extension;
                //$uploaded_file=$result["l_name_en"].$result["id"].$filename;
                //ftp_upload($_FILES['userfile']['tmp_name'],$uploaded_file,"Personnel/");
                //move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir.$uploaded_file);//change to below

                
    move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir.$_FILES['userfile']['name']);
                
    //chmod($uploaddir.$uploaded_file, 0777);
                
    }
            else
                
    header("location:census.php?import=personnel&notice=4");
        } 

    Did you know MS Office 2007 uses a different mime type? docx is the new type for MS Word Docs. How about letting users upload Open Office docs too!!

    PS. if you use PHP tags instead of CODE tags you'll get syntax highlighting.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles