I want to send a file to a remote server in PHP. When I make the file name hard-coded, the following code works fine:
$output = shell_exec('curl -XPOST -F "file=@myfile.txt" http://135.195.42.168:6007');
echo "<pre>$output</pre>";
Now I need to decide "file=@myfile.txt" dynamically. I tried the following:
$filePath = $_SERVER['DOCUMENT_ROOT'].'package/myzip_'.$owner_id.'.zip';
$name = basename($filePath);
$content = "file=@{$name}";
$output = shell_exec('curl -XPOST -F $content http://135.195.42.168:6007');
echo "<pre>$output</pre>";
Unfortunately, the above code does not work. Any better suggestion, please?