frontcode icon indicating copy to clipboard operation
frontcode copied to clipboard

如何將檔案存放至本地端

Open evaliu9457 opened this issue 7 years ago • 0 comments

你好,

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

evaliu9457 avatar Sep 04 '18 14:09 evaliu9457