I have a problem trying to upload a photo to my local server, everything works fine if I use an action and refer to the folder where my php file is, but it's not what I need because it redirects me to an empty page, I need to redirect myself to another html outside the server and save the image inside my folder on the local disk, I do not know if my JS file is wrong because apparently it can not execute.
PHP
<?php
$tmp_name = $_FILES['img_up']["tmp_name"];
$name = $_FILES['img_up']["name"];
$nuevo_path="apkw/img/".$name;
move_uploaded_file($tmp_name,$nuevo_path);
?>
JS
$(document).ready(function() {
read(0);
});
var host = "http://localhost:8080";
function read() {
$.ajax({
method: "POST",
url: host + "/subir.php"
}).done(function(data) {
$("#nel").empty();
if (data.length > 0) {
var html = "";
$.each(data, function(i) {
console.log(data[i]);
html += '';
})
}
});
}
HTML
<!DOCTYPE html>
<html>
<body>
<form enctype="multipart/form-data" method="post">
<input type="file" name="img_up">
<input value="Subir" type="submit" >
</form>
<script type="text/javascript" src="js/prueba.js"></script>
</body>
</html>