上传报告HTTP错误404,即使上传成功
Uploadify reporting HTTP ERROR 404, even though upload is successful
我已经将jQuery Uploadify集成到我的WordPress插件中,用于多个文件上传。Flash上传表单生成得很好,我可以选择文件并开始上传。Uploadify对所有尝试的文件报告"HTTP错误"。使用onError(),我看到404错误。
奇怪的是,文件上传正在成功处理。新文件出现在我的uploads文件夹中,并创建了一个数据库记录。那么,为什么Uploadify报告失败呢?
任何帮助都是非常感激的。下面是我使用的代码:Uploadify JS
$(document).ready(function() {
$('#file_upload').uploadify({
'scriptData': {'sid': '{$_REQUEST['gallery_uid']}'},
'uploader' : '{$plugin_url}upif/uploadify.swf',
'script' : '{$plugin_url}upif.php',
'cancelImg' : '{$plugin_url}upif/cancel.png',
'auto' : true,
'multi' : true,
'simUploadLimit' : 3,
'fileExt' : '*.jpg;*.gif;*.png;*.zip',
'fileDesc' : 'Image Files'
});
});
上传文件处理程序PHP
<?php
@require_once('../../../wp-blog-header.php'); // Pull in WP functions in order to write to DB
$uid = $_REQUEST['sid']; // Assigned Gallery UID
if (!empty($_FILES)) {
$file_temp = $_FILES['Filedata']['tmp_name'];
$file_orig = basename( $_FILES['Filedata']['name'] ) ;
$exts = explode( '.', $file_orig );
$file_ext = strtolower('.' . $exts[count($exts)-1]);
$file_save = $uid . '_' . date('ymd') . time() . $exts[0] . $file_ext;
$upload_dir = wp_upload_dir();
$target_path = $upload_dir['path'] . '/' . $file_save;
move_uploaded_file( $file_temp, $target_path ); // Move the file to WP's "uploads" path, using generated name
$insert = array(
'guid'=> $uid,
'path'=> $file_save,
'sort_order'=> '0',
'date_created' => date('Y-m-d H:i:s')
);
$wpdb->insert( $wpdb->prefix . 'images', $insert ); // Create DB record
echo '1'; // Success
}
SOLVED:经过进一步的探索,我能够让事情工作。php包含一定影响了输出。我的解决方案是以不同的方式包含。
我删除了PHP处理程序顶部的include,并将其替换为:<?php
@require_once('../../../wp-config.php'); // Pull in WP config elements
@require_once('../../../wp-includes/wp-db.php'); // Pull in WP DB functions
经过进一步的探索,我能够让事情工作。php包含一定影响了输出。我的解决方案是以不同的方式包含。
我删除了PHP处理程序顶部的include,并将其替换为:<?php
@require_once('../../../wp-config.php'); // Pull in WP config elements
@require_once('../../../wp-includes/wp-db.php'); // Pull in WP DB functions
相关文章:
- 解析云代码错误:解析.错误{代码:141,消息:“未调用成功/错误”}
- 解析查询.首次成功/错误 间歇性不调用回调
- 未调用成功/错误
- 当 AJAX 响应成功时清除 jquery 成功/错误消息 span 类
- 在 AngularJS 中声明一个承诺,并带有命名的成功/错误回调
- JQuery - 不要在按钮成功/错误时添加悬停类
- jQuery:在成功/错误中使用延迟对象(ajaxSetup 选项)
- 创建一个成功/错误的承诺,例如像ajax
- jquery.couchdb.js Ajax 成功/错误未被调用
- 未调用成功/错误 - 解析代码 141
- 处理开机自检后从 Angular 控制器到指令的成功/错误 DOM 操作
- node.js未找到解析成功/错误,未定义响应
- 使用JQuery以不可见的方式调用URL并返回成功/错误标志
- 解析云代码嵌套查询时未调用代码141成功/错误消息
- 表单提交的成功/错误信息没有显示
- 如何绑定引导加载按钮成功/错误在表单提交
- Ajax响应给出数据成功错误
- 在'fetch'之后没有调用成功/错误回调;(Backbone.Collection)
- 主干:正确的传递方式'this'在成功/错误回调中引用匿名函数
- jquery' ajax的哪个部分(成功/错误)接收到重定向状态码?