Php 移动上传的文件()可以';t在托管服务器中上载文件
在安装了apache的本地主机服务器中,我可以很好地上传文件。但当我将所有内容移动到托管服务器(如Altervista.org)时,文件不会上传 以下是html代码:Php 移动上传的文件()可以';t在托管服务器中上载文件,php,html,ajax,upload,Php,Html,Ajax,Upload,在安装了apache的本地主机服务器中,我可以很好地上传文件。但当我将所有内容移动到托管服务器(如Altervista.org)时,文件不会上传 以下是html代码: <form id="fileupload" action="" method="POST"> <input id="filesupload" type="file" multiple name="files" accept=".jpg" accessKey="PDF"/> <button id
<form id="fileupload" action="" method="POST">
<input id="filesupload" type="file" multiple name="files" accept=".jpg" accessKey="PDF"/>
<button id="MegaUpload" type="button" class="btn btn-primary start" onclick="conversion()">
</form>
if (isset($_FILES['fileToUpload'])) {
if (!isset($_COOKIE['users'])) {
setcookie('users', md5(time()/1234), time() + (86400), "/");
}
if (!file_exists('files/uploads/' . $_COOKIE['users'] . '/')) {
mkdir("files/uploads/" . $_COOKIE['users'], 0755);
mkdir("files/uploads/" . $_COOKIE['users'] . "/tmp", 0755);
}
$target_dir = 'files/uploads/' . $_COOKIE['users'] . '\/tmp\/';
for ($s=0; $s <= 10; $s++) {
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"][$s]);
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"][$s],
$target_file)) {
//ok
}
else{
//something wrong
}
}
}
$("#filesupload").change(function(evnt) {
var fd = new FormData();
for (var s = 0; s < ins; s++) {
fd.append("fileToUpload[]", document.getElementById('filesupload').files[s]);
}
$.ajax({
url: 'upload.php', // point to server-side PHP script
dataType: 'text', // what to expect back from the PHP script, if anything
cache: false,
contentType: false,
processData: false,
data: fd,
type: 'post',
async: false,
success: function(result){
alert(result);
},
error: function(result) {
alert(result);
}
});
}
我使用警报和回音进行了测试,我知道服务器收到了文件,但没有上传。创建一个
<?php phpinfo(); ?>
文件,并检查文件上传的部分。这应该是开着的
如果该选项为OFF或FALSE,则您可能无权上传文件。为此,您应该联系托管服务器的管理员。如果您是root用户,您可以使用以下链接将此状态设置为ON:我真的以为这是答案,但不幸的是,它仍然不起作用,因为php.ini中的文件上传部分已在宿主服务器中设置为ON。请检查一下该文件夹的文件权限。您可能没有写入权限。数值应该是644。再次检查,我也将数值“0777”放在所有文件夹中,但仍然没有答案。我应该在文件上放一些执行权限吗?我看到他们仍然在'0644'tho…也许你应该创建一个新的文件并构建一个非常简单的框架。用HTML创建一个表单,并将表单与提交到新PHP文件链接。因此,您可以更好地调试它,并可能在源代码中发现错误。也许这个链接会对你有所帮助:评论不是用来进行长时间讨论的;这段对话已经结束。