Skip to content

如何將檔案存放至本地端 #5

Description

@evaliu9457

你好,

$.ajax({
            url: 'http://zhangykwww.yind123.com/webapi/feedback',
            type: 'POST',
            data: formFile,
            async: true,  
            cache: false,  
            contentType: false, 
            processData: false, 
            // traditional:true,
            dataType:'json',
            success: function(res) {
                console.log(res);
            }
        })

這一段看起來是將檔案存放至雲端,請問如果要存放至本地端,是不是應該還有一個接收檔案的程式,像是這樣的

<?php
    
    if(is_array($_FILES)) {
        if(is_uploaded_file($_FILES['file']['tmp_name'])) {
            $sourcePath = $_FILES['file']['tmp_name'];
            $targetPath = "images/".$_FILES['file']['name'];
        
        if(move_uploaded_file($sourcePath,$targetPath)) {
            $newname = "temp-.jpg";
            rename($targetPath,"images/".$newname);
            $targetPath = "images/".$newname;
            }
        }
    }
?>

然後把這一行
url: 'http://zhangykwww.yind123.com/webapi/feedback',
改成
url: 'upload.php',
可是不知道哪裡出錯,總是無法存檔至本地端~~

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions