Uploadify 不上传文件,但表示成功 [英] Uploadify not uploading file, but indicates success

查看:26
本文介绍了Uploadify 不上传文件,但表示成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一些与我遇到的问题相同的帖子,但是没有提供解决方案.我不是 100% 确定该怎么做,但希望您能提供帮助.

I have found some posts with the same problem I have, however, no solutions presented. I am not 100% sure what to make of this, but hope you can help.

我正在尝试使用 Uploadify 上传文件,但发生了以下情况:

I am attempting to use Uploadify to upload files, but the following happens:

  1. 浏览文件成功(因此我的脚本"和上传"属性是正确的)
  2. 进度条显示100%"并完成.
  3. onComplete 触发说上传成功(根据警告的路径,'folder' 属性是正确的.)
  4. 如果我在任何输出之前终止我的脚本,#3 步骤就不会发生 - 因此它到达指定的脚本".输出后,脚本不会死.
  5. 在文件系统中找不到文件

不确定这怎么可能 - 据我所知,一切都是正确的.

Not sure how this is possible - as far as I can tell, everything is correct.

这是我的代码:

<script type="text/javascript"> 
    $(document).ready(function() {
        $("#addimage").validationEngine();
        $('#imagefile').uploadify({
            'uploader': "/js/uploadify/uploadify.swf",
            'fileExt': "*.jpg;*.jpeg;*.png;*.gif",
            'buttonText': "Browse...",
            'script': "/js/uploadify/uploadify.php",
            'cancelImg': "/js/uploadify/cancel.png",
            'folder': "/uploads",
            'fileDesc': 'Only *.jpg, *.jpeg, *.png, *.gif are allowed',
            'auto': true,
            'onComplete': function(event, ID, fileObj, response, data) {
                $('#name').val('Please edit this text to add a description...');
                alert('Uploaded ' + fileObj.name + ' to ' + fileObj.filePath + '.');
            }
        });        
    });
</script>

<input type="file" id="imagefile" name="imagefile" />

<?php

    if (!empty($_FILES)) {
        $tempFile = $_FILES['Filedata']['tmp_name'];
        $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
        $targetFile =  str_replace('//', '/', $targetPath) . 'image_' . date('YmdHis') . '_' . $_FILES['Filedata']['name'];
        move_uploaded_file($tempFile,$targetFile);
        echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);
    }

?>

PHP 脚本的唯一更改是我更改的 targetFile 的名称,以确保某种唯一的文件名(虽然不是万无一失),但脚本与发布的相同(为简洁起见,此处删除了注释).

The PHP script's only change is the name of the targetFile which I have changed, to ensure some sort of unique filename (although not foolproof) but otherwise the script is the same as released (with comments removed here for brevity purposes).

谁能告诉我为什么Uploadify显示文件上传成功,但uploads目录下没有文件?我使用的是 Windows,PHP5.3,并且上传文件夹是可写的(我可以在没有 Uploadify 的情况下上传文件,但不能使用它)

Can anybody tell my why Uploadify indicates that the file upload was successful, but no file exists in the uploads directory? I am using Windows, PHP5.3, and the uploads folder is writable (I can upload files there without Uploadify, but not with it)

提前致谢!

科布斯

推荐答案

我在 Linux 机器上遇到了类似的问题.原来我服务器上的PHP配置是cuplrit.PHP 在安全模式下运行.由于我已通过 FTP 上传了 Uploadify 脚本,因此脚本文件与我的 FTP 用户详细信息一起存储在文件系统中.由于 PHP 的临时文件夹归服务器根目录所有,我的 UID 不匹配,即临时上传文件归于 root,而试图移动它的上传脚本归 FTP 用户所有.这让它崩溃了.

I had similar problems on a Linux machine. It turned out that the PHP configuration on my server was the cuplrit. PHP was running in SAFE MODE. As I had uploaded the Uploadify scripts via FTP, so script files were stored in the file system with my FTP user details. Since PHP's temp folder was owned by the server root, I had a UID mismatch, i.e. the temporary upload file was attributed to root while the upload script that tried to move it was owned by the FTP user. That fragged it.

为了解决这个问题,我将uploadify php脚本的所有权更改为root,然后它就可以工作了.

To resolve this I changed the ownership of the uploadify php script to root and from there on it worked.

这篇关于Uploadify 不上传文件,但表示成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆