2011-12-13 66 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