html5文件上传器/ move_uploaded_file问题

时间:2012-07-02 19:56:40

标签: php html5 file upload

我发现一个插件是一个我喜欢的html5文件上传程序(可恢复),并且当文件保存到硬盘时,除了服务器(php)端外,一切都正常工作。也许有人可以看看并给我建议?因为我一直收到日志错误消息,我怀疑我有@move_uploaded_file和权限问题?或者,如果有人可以让我知道在哪里查找任何php错误,那也是有用的。我是初学者。

$temp_dir = '/public_html/uploads/'.$_POST['resumableIdentifier'];
$dest_file =     '/public_html/uploads/'.$_POST['resumableFilename'].'.part'.$_POST['res      umableChunkNumber'
// create the temporary directory
@mkdir($dir, 0777, true);

// move the temporary file
if (!@move_uploaded_file($file['tmp_name'], $dest_file)) {      
_log('Error saving (move_uploaded_file)';

2 个答案:

答案 0 :(得分:1)

为什么要使用@mkdir& amp;来抑制错误消息? @move_uploaded_file?删除@,写ini_set('display_errors', 1);
error_reporting(E_ALL);
在脚本的开头,如果你没有看到php-errors并查看哪些消息出现。

同时检查您的变量。您正在设置$ temp_dir,但尝试使用$ dir创建目录。

答案 1 :(得分:0)

我刚刚应用了一些化妆品并纠正了代码中的一些错误。不得不假设一些事情。临时目录只需要创建一次(我猜?)。

$temp_dir = '/public_html/uploads/'.$_POST['resumableIdentifier'].'/';
$dest_file = $temp_dir . $_POST['resumableFilename'] . '.part' . $_POST['resumableChunkNumber'];

// create the temporary directory
if (!is_dir($temp_dir) {
    if (!mkdir($temp_dir, 0777, true)) {
        _log('Error creating directory (mkdir)');
    }
}

// move the temporary file
if (!move_uploaded_file($file['tmp_name'], $dest_file)) {
    _log('Error saving (move_uploaded_file)';
}