PHP move_uploaded_file没有上传

时间:2015-09-29 10:11:40

标签: php

我在PHP中使用此代码:

if($at[is_attachment]==1) {
    $filename = $ticketnumber."-".date("YmdHis").'-'.$at[filename];
    $target_path = '../../../media/ticket_attachments/';
    $target_path = $target_path.$filename; 
    if(move_uploaded_file($at[attachment], $target_path)) {
        echo 'yes';
    }
}

但是它没有将文件移动到该位置,运行的脚本位于:

admin > autochecks > helpdesk > emails.php

media目录位于admin

之外

我试过了:

move_uploaded_file($at[attachment], $target_path)

但这只是显示bool(false)

mediaticket_attachments目录上的

权限均为777

4 个答案:

答案 0 :(得分:1)

移动代码应为

move_uploaded_file($_FILES["attachment"]["tmp_name"], $target_path))

PHP 5 File Upload

答案 1 :(得分:0)

变化:

$target_path = '../../../media/ticket_attachments/';

要:

$target_path = './../../../media/ticket_attachments/';

答案 2 :(得分:0)

move_uploded函数用于移动从请求上传的文件,并且处于临时文件状态。

尝试 -

if($at[is_attachment]==1) {
    $filename = $ticketnumber."-".date("YmdHis").'-'.$at[filename];
    $target_path = '../../../media/ticket_attachments/';
    $target_path = $target_path.$filename; 
    if(copy($at[attachment], $target_path)==1 ) {
        if(unlink($at[attachment])){
        echo 'yes';
        }
    }
}

答案 3 :(得分:0)

尝试更改此路径:

    $target_path = '../../media/ticket_attachments/';

有了这个:

.fix-top-table {
     position: fixed;
     left: 0;
     top: 0;
     border-bottom: 1px #39F solid;
     max-width: 100%;
     width: 100%;
     height: 60px;
     padding: 0px;
     background: white;
     z-index:10;
 }

 #page-content
{
    position: absolute;
    left: 160px;
    top: 70px;
    z-index: 1;
}