Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tastemedia's avatar

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.

0 likes
2 replies
Snapey's avatar

why would you use a framework and then side step it with a plain old php file

1 like

Please or to participate in this conversation.