2011-12-13 120 views
1

由於我對我已經使用jQuery和PHP文件上傳到服務器,減少HTTP請求的數量的文件上傳任務工作。除了文件上傳以外,從管理控制面板中一切都很好。文件上傳在本地主機上正常工作,但是當我在實時服務器環境中處理這些文件時,文件無法上傳。 IHAVE更改文件權限0777PHP文件上傳(圖片和Flash文件)問題

奇怪的權限會自動將其設置爲777後,或改爲755後,您上傳的遊戲。

其實這個過程是: - 我存儲兩個文件,即,圖像和.swf文件在一個目錄 - 目錄獲取與它的數據庫表中的id 創建 - 遊戲文件和遊戲圖像都沒有得到上傳在相應的目錄

例如,遊戲ID 342被提供一個目錄名創建一個名爲342,但圖像和SWF文件不在該目錄中得到上傳。對於每個遊戲,相應的目錄都是通過遊戲ID創建的。

我的代碼: 文件名:uploadify.php

if (!empty($_FILES)) { 
     $tempFile = $_FILES['Filedata']['tmp_name']; 
     $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/'; 
     $targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name']; 

     $fileTypes = str_replace('*.','',$_REQUEST['fileext']); 
     $fileTypes = str_replace(';','|',$fileTypes); 
     $typesArray = split('\|',$fileTypes); 
     $fileParts = pathinfo($_FILES['Filedata']['name']); 

      mkdir(str_replace('//','/',$targetPath), 0755, true); 
      move_uploaded_file($tempFile,$targetFile); 
      chmod($targetFile,0777); 
      echo "1"; 

    } 

jQuery的文件:js.js

$('#fileinput').uploadify({ 
     'uploader' : 'uploader/uploadify.swf', 
     'script' : 'uploader/uploadify.php', 
     'cancelImg' : 'uploader/cancel.png', 
     'auto'  : true, 
     'folder' : "../../../games/"+$("#newgameid").val()+"/", 
     'onComplete' : function(event,queueID,fileObj){ 
      $("#flashfileupload").html("file<strong>: "+ fileObj.name + " ("+ Math.round(fileObj.size/1000) + " kb)</strong> has been uploaded successfully!");  
      $("#size").val(Math.round(fileObj.size/1000)); 
      $("#filename").val(fileObj.name); 
      $("#submitgame").removeAttr("disabled"); 
     }, 
     'onOpen' : function(event,queueID,fileObj){ 
      if(fileObj.name.indexOf(".swf")==-1){ 
       alert('Error Input - Flash game must SWF File!') 
       $('#fileinput').uploadifyClearQueue(); 
      } 
     } 


    }); 


    $('#thumnail').uploadify({ 
     'uploader' : 'uploader/uploadify.swf', 
     'script' : 'uploader/uploadify.php', 
     'cancelImg' : 'uploader/cancel.png', 
     'auto'  : true, 
     'folder' : "../../../games/"+$("#newgameid").val()+"/", 
     'onComplete' : function(event,queueID,fileObj){ 
      $("#thumnailfileupload").html("file<strong>: "+ fileObj.name + " ("+ Math.round(fileObj.size/1000) + " kb)</strong> has been uploaded successfully!"); 
      $("#thumbnail").val(fileObj.name); 
     } 

    }); 

請幫我在這方面。感謝您閱讀此問題的時間。任何建議都被接受。

問候, phphunger。

回答

0

你的mkdir()函數調用的權限設置爲0755:

mkdir(str_replace('//','/',$targetPath), 0755, true); 

嘗試將其設置爲777:

mkdir(str_replace('//','/',$targetPath), 0777, true); 
+0

喜倫敦的,感謝您的回覆。我已經改變它,但文件夾被創建,但沒有圖像和Flash內容,而文件夾權限保持0755.即使我試圖將其更改爲0777更改不適用於它。即使我不能上傳文件手動也.. – phphunger

+0

作爲一個全面的檢查,有你確信你的php.ini讓你想大小的上傳?您可以顯示$ _FILES或$ targetFile的任何調試輸出? – landons

+0

其實這個過程在本地主機上正常工作,但在ftp上傳中有問題。無論如何,我有一個.htaccess文件,看到可能是下面的代碼限制不上傳文件。代碼是php_value post_max_size 80M php_value upload_max_filesize 80M php_value max_execution_time 120 – phphunger