简体   繁体   中英

How to store uploaded file into server path using either javascript or jquery

I want to know that how can I store my uploaded file from my local system into one server path like( '/newfolder/tests/' ) using either javascript or jquery, Please provide me any solution for it as I'm new to this Files system.

html:

  <input type="file" id="inputfile" name="inputfile"></input>

js:

  var path =$('input[type=file]').val().replace(/C:\\fakepath\\/i, '');

is giving my uploaded file names only`, so that I need to store/save this variable on any server path(or any File system path),and I'm not using any database here, so that I can grab it from that path and can display it on my view page.

Try This

$('#imageInput').change(function(){
var frm = new FormData();
frm.append('imageInput', input.files[0]);
$.ajax({
    method: 'POST',
    address: 'url/to/save/image',
    data: frm,
    contentType: false,
    processData: false,
    cache: false
});

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM