move上载的文件无法打开流:没有此类文件或目录

r6l8ljro  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(324)
<?php
    if(isset($_FILES['file'])) 
    { 

      $original_url='adminPanel/Images/';
      $currentDate = new DateTime();
      $currentTimestamp = $currentDate->format("YmdHis");
      $randomNumber= mt_rand(1111, 9999);
      $filePath=$_FILES['file']['name'];
      $fileName = $currentTimestamp.$randomNumber.$filePath;
      $source = $_FILES['file']['tmp_name'];
      $ext = end((explode(".", $filePath)));//take extension from image/video 
      $fileName = $currentTimestamp.$randomNumber.".".$ext;  
      $original = $original_url.$fileName;  
         move_uploaded_file($source,$original ); 
    }

?>

php警告:移动上传的文件(adminpanel/images/201704210824047891.jpg):无法打开流:第19行的g:\pleskvhosts\sinnonteq.com\qhawk.sinnonteq.com\adminpanel\product.php中没有此类文件或目录
php警告:move_uploaded_file():无法将第19行g:\pleskvhosts\sinnonteq.com\qhawk.sinnonteq.com\adminpanel\product.php中的“c:\windows\temp\phpc5ee.tmp”移动到“adminpanel/images/201704210824047891.jpg”

e4eetjau

e4eetjau1#

很抱歉,在编辑之前没有回答问题。
最新答案
最好检查您使用的文件和位置是否存在。
你可以用 is_file() 要检查文件是否存在,请执行以下操作: is_uploaded_file() 检查文件是否存在,如果源文件存在,则通过http post上载。
你可以用 is_dir() 检查目标文件夹是否存在。
如果它不存在,您可以先用 mkdir()

相关问题