I am trying to send mail with attachment after using browse button.

in this process some error shows

Warning: move_uploaded_file() [function.move-uploaded-file]: open_basedir restriction in effect. File(/tmp/php_upload/phpLc37tw) is not within the allowed path(s):

thsese are code for my mail file

$filename=$_FILES["strresume"]["name"]; 
    $filetype=$_FILES["strresume"]["type"]; 
    $filesize=$_FILES["strresume"]["size"]; 
    $filetemp=$_FILES["strresume"]["tmp_name"];

$fp = fopen($filetemp, "rb"); 
    $file = fread($fp, $filesize); 

    $file = chunk_split(base64_encode($filename)); 
    $num = md5(time()); 
    
       
    $headers  = "From: yourname<youraccount@yourdomain.com>\r\n"; 
       $headers  .= "MIME-Version: 1.0\r\n"; 
       $headers  .= "Content-Type: multipart/mixed; "; 
       $headers  .= "boundary=".$num."\r\n"; 
       $headers  .= "--$num\r\n"; 
        // This two steps to help avoid spam    
// This two steps to help avoid spam    

    $headers .= "Message-ID: <".gettimeofday()." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n"; 
    $headers .= "X-Mailer: PHP v".phpversion()."\r\n";          

        // With message 
        
    $headers .= "Content-Type: text/html; charset=iso-8859-1\r\n"; 
       $headers .= "Content-Transfer-Encoding: 7bit\r\n"; 
       $headers .= "".$message."\n"; 
       $headers .= "--".$num."\n";

        
     // Attachment headers 

    $headers  .= "Content-Type:".$filetype." "; 
       $headers  .= "name=\"".$filename."\"r\n"; 
       $headers  .= "Content-Transfer-Encoding: base64\r\n"; 
       $headers  .= "Content-Disposition: attachment; "; 
       $headers  .= "filename=\"".$strresume_name."\"\r\n\n"; 
       $headers  .= "".$file."\r\n";
     //  $headers  .= "--".$num."--"; 
    
    // SEND MAIL 
        
       mail($to, $subject, $message, $headers);

my browse button is

<input type="file" name="strresume" style="height:25px;" />

this is the form pagehttp://migrantaustralia.com/applyonline.html

PHP open_basedir protection tweak is a Safe Mode security measure that prevents users from opening files or scripts located outside of their home directory with PHP, unless the folder has specifically excluded. PHP open_basedir setting, if enabled, will ensure that all file operations to be limited to files under certain directory, and thus prevent php scripts for a particular user from accessing files in unauthorized user’s account. When a script tries to open a file with, for example, fopen() or gzopen(), the location of the file is checked. When the file is outside the specified or permissible directory-tree, PHP will refuse to open it.

It's a server configuration issue. Files will, by default be stored in the server's default temporary directory, unless another location has been given with the upload_tmp_dir directive in php.ini. The server's default directory can be changed by setting the environment variable TMPDIR in the environment in which PHP runs. Setting it using putenv() from within a PHP script will not work.

My 2¢. Hope this helps. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.