图片上传错误

时间:2011-09-21 06:50:53

标签: php

我已经在位置'cms / user / prescriptionimg'创建了目录但是我在上传文件时遇到错误。

 Warning: move_uploaded_file(../cms/user/prescriptionimg/11500004-21000002-13165874331.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/oxfordmo/public_html/cms/user/prescription.php on line 113

 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpdCWdaR' to '../cms/user/prescriptionimg/11500004-21000002-13165874331.jpg' in /home/oxfordmo/public_html/cms/user/prescription.php on line 113

 Unable to move user 11500004-21000002-13165874331's picture to prescription directory

关于这个的脚本是......

  if (file_exists("../cms/user/prescriptionimg/$username.$ext")) 
    {unlink("../cms/user/prescriptionimg/$username.$ext"); }
  if (!move_uploaded_file($_FILES["scaninput".$i]['tmp_name'],"../cms/user/prescriptionimg/$username.$ext")) 
            { die("Unable to move user $username's picture to prescription directory"); }

1 个答案:

答案 0 :(得分:1)

使用此函数检索根路径。

 $root = realpath($_SERVER["DOCUMENT_ROOT"]);


                  //-----------------------------------
                  // require the functions file
                  //-----------------------------------
                  //require ("$root/php/funkshions.php");