文件上传脚本问题

时间:2014-04-21 17:01:48

标签: php file

我的文件上传脚本有问题这是函数(jp_upload_pic())我有问题的具体是move_uploaded()函数,第二个参数“destination”这是我的值(“../ usr / ceo / JPCEO_20“)但这个错误告诉我。

  

警告:第1115行/var/www/jobinpal/includes/func.php中的move_uploaded_file(../usr/ceo/JPCEO_20): failed to open stream: No such file or directory in /var/www/jobinpal/includes/func.php on line 1115 Warning: move_uploaded_file(): Unable to move '/tmp/phpgf1k7y' to ' ../ usr / ceo / JPCEO_20'

function jp_upload_pic()
{
    if (isset($_GET['upload'])) {
        $jp_img=$_FILES['file_to_be_uploaded'];

        // file uploader for jobinpal...
        $jp_img_name=$jp_img['name'];// name of the file
        $jp_img_type=$jp_img['type'];
        $jp_img_size=$jp_img['size'];
        $jp_img_tmp_name=$jp_img['tmp_name'];//$_FILES['userfile']['tmp_name'] 
        $jp_img_err=$jp_img['error'];// the error of the file...


        // check if the image post isset before working...
        if (isset($jp_img)) {

          //do the string of the file name to get the .xxx extension
            $jp_img_name_len=strlen($jp_img_name);
            $jp_img_ext=substr($jp_img_name ,-4, $jp_img_name_len );

            //check the image type of the image
            $jp_img_size;
            if (
                 /* file must be any of this format else bounce */
                 (
                 ($jp_img_ext == '.jpg') ||
                 ($jp_img_ext == '.png') ||
                 ($jp_img_ext == '.gif')
                 ) && ($jp_img_size < 10240)
               ) 
            {
              //call the session file to get the current user
              include("jobinpal_session.php");
              $jp_usr_verified_ses=$_SESSION['jp_new_usr'];

              //use the user session to create a folder in the 'usr/ceo' folder
              //*** pattern for the foldername ***//
              //------>>> JPCEO_ID_FILEID

              //write a function to ouput from the database if...
              //the user is a ceo,staff,student account

              //function jp_check_usr_acc()
              //{
                $jp_usr_verified_ses=$_SESSION['jp_new_usr'];

                //*****-----------------------------******//
                //----------------------------------------//
                //*****-----------------------------******//

                include('jobinpal_db_config.php');
                $jp_run=$jobinpal_db_lite->query("SELECT account_type,id FROM  `jp_user` WHERE email='$jp_usr_verified_ses'");
                //$jp_aff_rows=$jobinpal_db_lite->affected_rows;


                while ($jp_result=$jp_run->fetch_array(MYSQLI_BOTH)) {
                   $jp_results[] = $jp_result;
                }

                foreach ($jp_results as $jp_result) {
                   $jp_res=$jp_result['account_type'];
                   $jp_res=strtoupper($jp_res);

                   $jp_res2=$jp_result['id'];
                }

                rmdir('../usr/ceo/JPCEO_20');

                if (!is_dir("../usr/ceo/"."JP".$jp_res."_".$jp_res2))
                {
                   mkdir("../usr/ceo/"."JP".$jp_res."_".$jp_res2, 0700);
                   $JP_new_usr_dir="../usr/ceo/"."JP".$jp_res."_".$jp_res2;
                   $JP_new_usr_dir="JP".$jp_res."_".$jp_res2;

                   //please i am having issues with the file uploads please put it stackoverflow
                   //for help...(?)
                   move_uploaded_file($jp_img_tmp_name,"`../usr/ceo/".$JP_new_usr_dir);
                }

                //$path=/*"http://".$domain.*/".."."/"."jobinpal"."/"."usr"."/"."ceo"."/".$JP_new_usr_dir;
                //move_uploaded_file($jp_img_tmp_name,'../usr/ceo');
              //}

              //jp_check_usr_acc();

              // move the uploaded file to the directory created for the user...
              //move_uploaded_file($jp_img_tmp_name,$JP_new_usr_dir);



            }
            else
            {
              if (
                 /* file must be any of this format else bounce */
                 !
                 ($jp_img_ext == '.jpg') ||
                 ($jp_img_ext == '.png') ||
                 ($jp_img_ext == '.gif')
               )
              {
                echo "<h6 id='img_upload_err'>image must be this extensions (.jpg), (.png), (.gif)<h6>";
                return false;
              }
            }
        }



    }

}       

1 个答案:

答案 0 :(得分:0)

看起来像是一个错字:

move_uploaded_file($jp_img_tmp_name,"`../usr/ceo/".$JP_new_usr_dir);
                                     ^ is this supposed to be here?

您也会在错误消息中看到反引号,但不会在您创建和检查的目录中看到。