why would you use a framework and then side step it with a plain old php file
Mar 27, 2020
2
Level 1
Don´t get values from Ajax in PHP File
I want to generate a thumbnail from a .mp4 file with ffmpeg on the server. In /admin/create.edit.template i have a js function. I send the data via Ajax to a file in the root (it´s next to index.php)
ajax function:
function generateThumbnail() {
var videoUrl = $("#videothumbnail").val();
var arrayOfStrings = videoUrl.split("/");
var urlString = arrayOfStrings[3] + '/' + arrayOfStrings[4];
var videoId = $("#id").val();
var values = {
url: urlString,
id: videoId
};
$.ajax({
url: "https://mydomain.demo/generate-thumbnail.php",
type: "POST",
data: values,
success: function(data){
console.log("success:" + values.url + " id:" + values.id);
},
error : function (data) {
console.log("error: " + values);
}
});
}
in console i get success message and the right values.
I don´t understand why i don´t get any values in generate_thumbnail.php
<?php
$video = $_POST["values.url"];
$id = $_POST["values.id"];
var_dump($video);
var_dump($id)
...
Do i have to make Routes for this? If so, what would be the right way to do this? Any help or hint welcome.
thanks in advance.
Please or to participate in this conversation.