php - Not allowed to load local resource [image upload] -
here snippet ajax
server-side script uploads file being submitted. triggers on change
of input[type=file]
.
$('#maglogo').on('change', function(e) { var $input = $(this); var file = e.currenttarget.files[0]; var data = new formdata(); data.append('file', file); $.ajax({ type: "post", data: data, cache: false, contenttype: false, processdata: false, url: 'my/path/to/upload/script.php' }) .done(function(fullpath) { $input .parents('#maglogocont') .css('background-image', "url('"+fullpath+"')"); }); });
on other side, php script returns json string contains temporary directory of uploaded file (which looks file:///c:/wamp/tmp/filename.jpg
i'm running on windows).
the problem when want put image background of div show user has been uploaded, error in console says not allowed load local resource
). cannot upload directly in final directory information not available time user chooses image upload.
is there way of doing want do?
many thanks!
no, cannot integrate file browser via such "url"/path.
move image folder under httpfiles root of web-page , direct path in relative way.
Comments
Post a Comment