我正在处理一个文件上传任务,我使用jQuery和php将文件上传到服务器,以减少http请求的数量。从管理控制面板,一切都很好,除了文件上传。文件上传在本地主机上工作正常,但当我在现场服务器环境中工作时,文件没有上传。我已将文件权限更改为0777。
设置为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 .
你的mkdir()函数调用将权限设置为0755:
mkdir(str_replace('//','/',$targetPath), 0755, true);
尝试设置为777:
mkdir(str_replace('//','/',$targetPath), 0777, true);