Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
evaliu9457 opened this issue Sep 4, 2018 · 0 comments
Open

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

evaliu9457 opened this issue Sep 4, 2018 · 0 comments

Comments

@evaliu9457
Copy link

你好,

$.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',
可是不知道哪裡出錯,總是無法存檔至本地端~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant