How does php write api for others to use?

I now need to write an api
is a specific account where other people can upload videos to my server
, but I don"t know how to start? The concept of
is that
the counterpart can send the film to me through enctype= "multipart/form-data"
.
I will send URL back to the counterparty via json

.

I already have an upload mechanism

$_FILES["myFile_avatar"]
move_uploaded_file
Mar.03,2021

  1. first sort out the requirements, others upload to your server, only upload documents? Do you need additional information?
  2. secondly, you need to design the interface: do you need a unified directory? For example, how to implement this requirement through URL Rewrite if URL can be www.xxx.com/api/postFile,; whether the communication method is GET or POST (but you obviously need to use POST); to handle additional messages sent by users; correct / error messages returned by users after calling the API, etc.)
  3. all of the above are solved one by one, and then sorted out into interface documents.
  4. online joint tuning of the function.

Is the domain name of

api the same as the domain name of api caller ? If it is inconsistent, consider the cross-domain issue.

suppose the domain name of api is http://api.com, and the domain name of the caller is http://get.com.

I defined a api as follows:

// api
//  cors 
// 
header('Access-Control-Allow-Origin: http://get.com');
header('Access-Control-Allow-Credentials: true');

class UploadFile {
    public function upload(){
        //  ...
    }
}

call http://api.com/UploadFile/upload and then add the required parameters.

< hr >

caller js :

var apiUrl = 'http://api.com/UploadFile/upload';
// 
var formData = new FormData();
    // 
    formData.append('file' , file);
var xhr = new XMLHttpRequest();
    xhr.open('post' , apiUrl , true);
    xhr.onreadystatechange = function(){
        ...
    };
    xhr.send(formData);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e79ccd-78b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e79ccd-78b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?