为什么我的文件上传没有复制到目录? (javascript,php)

时间:2016-12-17 10:05:18

标签: javascript php json file upload

请帮助

这是我在类

中的构造函数
$this->covername = $image['cover']['name'];
$this->coverdir = $image['cover']['tmp_name'];
$this->covertype = pathinfo($this->covername, PATHINFO_EXTENSION);

这个json脚本

    prosesSave = function(saveas) {
    document.getElementById("saveas").value = saveas;
    var message = $('#message');
    var fields = $("#form1,#form2,#form3");
    var formdata = new FormData(fields[0]);

    $.ajax({
        type: "POST",
        url: "project/proses-new-page.php",
        data: formdata,
        cache: false,
        contentType : false,
        processData : false,
        dataType: 'json',
        success: function(response) {
            $(message).empty();
            if(response.saveas){
                if (saveas == 'Draft') {
                    var idmsg = $("<div></div>", {
                        "class":"callout callout-info"}).appendTo(message);
                }else{
                    var idmsg = $("<div></div>", {
                        "class":"callout callout-success"}).appendTo(message);
                }
            }else{
                var idmsg = $("<div></div>", {
                    "class":"callout callout-danger"}).appendTo(message);
            }
            $(idmsg).empty().html(response.html);
            document.getElementById("status").value = "EditPage";
            document.getElementById("idpage").value = response.idpage;
        }
    });
    return false;}

这是我的流程副本

    if ($this->covername) {
        $this->filename = $id."_".$this->date.".".$this->covertype;

        $this->move = $this->dirupload."cover/".$this->filename;
        if(!move_uploaded_file($this->coverdir, $this->move)){
            $this->response_html = '<p>Faild</p>'.$this->covername."<br>".$this->coverdir."<br>".$this->move;
        }else{
            $this->response_html = '<p>Succes</p>'.$this->covername;
        }

        chmod($this->move, 0777);

        mysqli_query($this->conn, "UPDATE tb_pages SET COVER_PAGE = '".$this->filename."' WHERE ID_PAGE = '".$id."'");
    }

我的代码有问题。在此代码名称中,类型等可以插入到数据库中。但是在图像上无法复制到目录($this->coverdir)。

我的英语不好。

0 个答案:

没有答案