jquery swfupload 的 upload.php 中应该包含哪些代码?
我刚刚开始使用 jquery swfupload 插件,除了上传部分之外,我的一切都在工作......我不知道要在 upload.php 文件中放入什么。
我收到错误:警报:{"name":"","type":"","size":""};文件:mayday-parade.png
upload.php 最初有代码:
$file = $_FILES['file'];
echo '{"name":"'.$file['name'].'","type":"'.$file['type'].'","size":"'.$file['size'].'"}';
显然这不起作用,但我添加了以下内容:
if (file_exists($_SERVER['DOCUMENT_ROOT'].'/band_photos/' . $_FILES["file"]["name"])) {
echo 'file exists';
} else {
$uploaddir = 'uploads/';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
if(move_uploaded_file($_FILES["file"]["tmp_name"], $uploadfile)) {
echo 'success';
} else {
echo 'error';
}
}
我似乎无法找出我做错了什么。有人可以帮忙吗?
I just started using the jquery swfupload plugin and I have everything working besides the upload part... I don't know what to put in the upload.php file.
I get the error: Alert: {"name":"","type":"","size":""}; File: mayday-parade.png
upload.php originally had the code:
$file = $_FILES['file'];
echo '{"name":"'.$file['name'].'","type":"'.$file['type'].'","size":"'.$file['size'].'"}';
obviously this doesn't work but i added the following:
if (file_exists($_SERVER['DOCUMENT_ROOT'].'/band_photos/' . $_FILES["file"]["name"])) {
echo 'file exists';
} else {
$uploaddir = 'uploads/';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
if(move_uploaded_file($_FILES["file"]["tmp_name"], $uploadfile)) {
echo 'success';
} else {
echo 'error';
}
}
I can't seem to find out what i'm doing wrong. Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否已将 SWFUpload 设置中的 file_post_name 更改为“file”?
如果没有,
$_FILES['file']
将不会返回任何内容,因为默认名称是 Filedata ,因此请使用$_FILES['Filedata']< /代码> 相反。
Have you changed the the file_post_name in SWFUpload's settings to "file"?
If not,
$_FILES['file']
will not return anything, because the default-name is Filedata , so use$_FILES['Filedata']
instead.