2014-10-09 63 views
1

我收到此錯誤信息:「沒有這樣的文件或目錄」雖然文件在那裏?

Warning: move_uploaded_file(uploads/1f77f7e78f36847859c0604e9645f112.jpg): failed to open stream: No such file or directory in C:\xampp\htdocs\ubergallery\multiple_image_upload\upload.php on line 17 

Warning: move_uploaded_file(): Unable to move 'C:\xampp\tmp\phpE035.tmp' to 'uploads/1f77f7e78f36847859c0604e9645f112.jpg' in C:\xampp\htdocs\ubergallery\multiple_image_upload\upload.php on line 17 
1).please try again!. 

「upload.php的」被包括內部「multiupload.php」,我期待包括「multiupload.php」內部「的index.php」,它坐落在這裏:

ubergallery/resources/themes/uber-blue/index.php 

其他兩個文件都位於這裏:

ubergallery/multiple_image_upload/multiupload.php 
ubergallery/multiple_image_upload/upload.php 

這是upload.php的:

<?php 
if (isset($_POST['submit'])) { 
    $j = 0; //Variable for indexing uploaded image 

    $target_path = "uploads/"; //Declaring Path for uploaded images 
    for ($i = 0; $i < count($_FILES['file']['name']); $i++) {//loop to get individual element from the array 

     $validextensions = array("jpeg", "jpg", "png"); //Extensions which are allowed 
     $ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.) 
     $file_extension = end($ext); //store extensions in the variable 

     $target_path = $target_path . md5(uniqid()) . "." . $ext[count($ext) - 1];//set the target path with a new name of image 
     $j = $j + 1;//increment the number of uploaded images according to the files in array  

     if (($_FILES["file"]["size"][$i] < 100000) //Approx. 100kb files can be uploaded. 
       && in_array($file_extension, $validextensions)) { 
      if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path)) {//if file moved to uploads folder 
       echo $j. ').<span id="noerror">Image uploaded successfully!.</span><br/><br/>'; 
      } else {//if file was not moved. 
       echo $j. ').<span id="error">please try again!.</span><br/><br/>'; 
      } 
     } else {//if file size and file type was incorrect. 
      echo $j. ').<span id="error">***Invalid file Size or Type***</span><br/><br/>'; 
     } 
    } 
} 
?> 

這是index.php文件:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 

<head> 
    <title>Qinter</title> 
    <link rel="shortcut icon" href="<?php echo THEMEPATH; ?>/images/favicon.png" /> 

    <link rel="stylesheet" type="text/css" href="<?php echo THEMEPATH; ?>/rebase-min.css" /> 
    <link rel="stylesheet" type="text/css" href="<?php echo THEMEPATH; ?>/style.css" /> 
    <?php echo $gallery->getColorboxStyles(5); ?> 

    <script type="text/javascript" src="//code.jquery.com/jquery-2.1.0.min.js"></script> 
    <?php echo $gallery->getColorboxScripts(); ?> 

    <?php file_exists('googleAnalytics.inc') ? include('googleAnalytics.inc') : false; ?> 



    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
    <script src="http://localhost/ubergallery/multiple_image_upload/script.js"></script> 

    <!-------Including CSS File------> 
    <link rel="stylesheet" type="text/css" href="http://localhost/ubergallery/multiple_image_upload/style.css"> 




</head> 
<body> 
<div class="imageupload clearfix"> 
    <?php 
    include($_SERVER['DOCUMENT_ROOT']. '/ubergallery/multiple_image_upload/multiupload.php'); 

    ?> 

    </div> 


<!-- Start UberGallery v<?php echo UberGallery::VERSION; ?> - Copyright (c) <?php echo date('Y'); ?> Chris Kankiewicz (http://www.ChrisKankiewicz.com) --> 
<div id="galleryWrapper"> 
    <div class="line"></div> 

    <?php if($gallery->getSystemMessages()): ?> 
     <ul id="systemMessages"> 
      <?php foreach($gallery->getSystemMessages() as $message): ?> 
       <li class="<?php echo $message['type']; ?>"> 
        <?php echo $message['text']; ?> 
       </li> 
      <?php endforeach; ?> 
     </ul> 
    <?php endif; ?> 


    <div id="galleryListWrapper"> 
     <?php if (!empty($galleryArray) && $galleryArray['stats']['total_images'] > 0): ?> 
      <ul id="galleryList" class="clearfix"> 
       <?php foreach ($galleryArray['images'] as $image): ?> 
        <li><a href="<?php echo html_entity_decode($image['file_path']); ?>" title="<?php echo $image['file_title']; ?>" rel="colorbox"><img src="<?php echo $image['thumb_path']; ?>" alt="<?php echo $image['file_title']; ?>"/></a></li> 
       <?php endforeach; ?> 
      </ul> 
     <?php endif; ?> 
    </div> 

    <div class="line"></div> 
    <div id="galleryFooter" class="clearfix"> 

     <?php if ($galleryArray['stats']['total_pages'] > 1): ?> 
     <ul id="galleryPagination"> 

      <?php foreach ($galleryArray['paginator'] as $item): ?> 

       <li class="<?php echo $item['class']; ?>"> 
        <?php if (!empty($item['href'])): ?> 
         <a href="<?php echo $item['href']; ?>"><?php echo $item['text']; ?></a> 
        <?php else: ?><?php echo $item['text']; ?><?php endif; ?> 
       </li> 

      <?php endforeach; ?> 

     </ul> 
     <?php endif; ?> 


    </div> 
</div> 
<!-- End UberGallery - Distributed under the MIT license: http://www.opensource.org/licenses/mit-license.php --> 

</body> 
</html> 

我希望你能與錯誤訊息的相關說明。

No such file or directory in C:\xampp\htdocs\ubergallery\multiple_image_upload\upload.php on line 17 

該文件絕對存在。

+0

只要在if(($ _FILES [「file」] [「size」] [$ i] <100000)上方''你可以在'$ _FILES'上做一個'var_dump'並粘貼結果? – Oxymoron 2014-10-09 15:58:08

+0

確保'upload'文件夾存在,並且具有適當的寫入權限,因爲它看起來像是在嘗試上傳到一個不存在的文件夾,您可能想用'ubergallery/multiple_image_upload'或'multiple_image_upload'代替'upload' – 2014-10-09 16:03:43

+0

感謝Fred-ii的回答,它看起來像「上傳」文件夾設置爲「只讀」,但取消選中此選項時,它將自己恢復爲「只讀」我不確定這是什麼設置此選項。 – ftxn 2014-10-09 16:26:23

回答

0

確保爲該腳本分配了相應的權限,並且在與標題爲uploads的腳本位於相同位置的文件夾中。 CHMOD是你要找的(儘量避免777,這只是懶惰)

此外,這是一個Windows主機?雖然這不要緊,你可以試試這個:

$target_path = "uploads" . DIRECTORY_SEPARATOR; //Declaring Path for uploaded images 
+0

感謝您的回答。我已經給Fred-ii寫了一條評論。 – ftxn 2014-10-09 16:27:47

+0

Oxymoron,我一直試圖在Windows中取消選擇文件夾「uploads」的「只讀」但它將自己重新設置爲「只讀」。你有什麼建議嗎?非常感謝。我也不確定文件夾從哪裏設置爲「只讀」? – ftxn 2014-10-09 16:30:16

+0

如果文件未正確檢出,某些源代碼管理系統會執行此操作。否則,我會建議使用Sysinternals(Windows)來觀察文件夾並確定設置此選項的內容。 – Oxymoron 2014-10-09 17:02:55

1

No Such File or Directory在這種情況下,最有可能意味着,無論是源文件目標目錄不存在。如果您確定文件存在,uploads/目錄缺失。

您可能希望將該目錄設置爲絕對路徑,以避免不同的腳本查找不同的目錄。

+0

感謝您的回答。我已經給Fred-ii寫了評論。 – ftxn 2014-10-09 16:26:54

相關問題