Moralis and PHP - 405 Error

I’m certain there is an issue in how I have the server set up, and I can’t find what I need here. I have code in Visual Studio Code, with several pages that have functioned fine after being pushed to Moralis, when they use Javascript (and the Moralis API).

However, I have a page that I am trying to use to create a .json metadata file for a simple NFT minting project. I have a .html page for minting, which has a form that POSTs over to a .php page (OnSubmit, it runs my NFT minting script, which functions perfectly on Rinkeby!, and it sends the browser to the proper php page). I dug in, and that form data is definitely passing through in the POST to the php page. However, the .php page just throws a 405 Error, when the intention is to take the POSTed data, and generate a .json file from it, which the NFT would then point to.

Here is the (very simple) php code in question:

if(isset($_POST['ShortName']) && isset($_POST['textdata'] && isset($_POST['fullID'])))  {
    $filename = dechex(preg_replace('#[^A-Za-z0-9_-]#', '', $_POST['fullID'])); //first, convert to Hex
    $filename = str_pad($filename, 64, "0", STR_PAD_LEFT);  //now, pad to 64 characters with 0s

    $file = $_SERVER['DOCUMENT_ROOT']."/$filename.json";
    $jsonData = array('fullID' => $_POST['fullID'], 'ShortName' => $_POST['ShortName'], 'textdata' => $_POST['textdata']);

    $jsonData =  json_encode($jsonData);
    $f = fopen($file, 'w');
    fwrite($f, $jsonData);
    echo 'Success.';
}  else  {
    echo 'Error.';

Any thoughts? Or, have I somehow fundamentally misunderstood Moralis? Right now, I’m on test networks. In the future, I’ll have web hosting, and so be able to just call the API, and run the PHP on my own server with more control over that, but for the time being, I’m trying to get things working in this environment.

Where is that php running now?

This is probably where my brain-fart is happening. It’s been deployed through “moralis-admin-cli deploy”, and I have been (baselessly) assuming I can run PHP scripts on a server. Is that not the case?

Yep, that is not not how it works, it will not interpret php

Well that answers my question! :laughing: Thanks, I’ll get cracking on setting up an environment where I can make this happen.