Answer the question
In order to leave comments, you need to log in
How to parse through json url?
I can't figure out how to parse the link in my case
On the server side
if (isset($_FILES["photo"])) {
$fileName = $_FILES["photo"]["name"];
$fileTmp=$_FILES["photo"]["tmp_name"];
$uploadFile = "C:/OpenServer/domains/futbolka/image/img/".$fileName;
$fileUploade = move_uploaded_file($fileTmp, $uploadFile);
if ($fileUploade == true) {
$response = [
"status"=> "ok",
"url"=> $uploadFile
];
} else {
$response = ["status" => "error"];
}
echo json_encode($response);
}
$("#fileForm").on("change",function(e){
e.preventDefault();
var fromData = new FormData($(this)[0])
$.ajax({
url: "unloade.php",
type: "POST",
data: fromData,
processData: false,
contentType: false,
success: function (data){
var event = JSON.parse(data,function(key, value){
if (key == "url") return new Date(value);
return false;
});
alert(event.data.getDate());
$("#urlAdress").attr("src", data.url);
alert("Отправлено"+data);
}
});
});
Answer the question
In order to leave comments, you need to log in
It would be necessary to give the correct url in JS:
$uploadFile = "//futbolka.ru/image/img/".$fileName;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question