I have been trying to create an upload.php script however the condition doesn't seem to work and PHP can not move the uploaded file to the folder upload.
Apache2 log output below
PHP Warning: move_uploaded_file(): The second argument to copy() function cannot be a directory in /var/www/html/upload.php on line 18, referer: http://192.168.0.110/stream.php
PHP Warning: move_uploaded_file(): Unable to move '/tmp/phpC34Agu' to '/var/www/html/upload/' in /var/www/html/upload.php on line 18, referer: http://192.168.0.110/stream.php
Upload.php code
<?php
$target_path = "/var/www/html/upload/";
$target = $target_path . basename($_FILES['uploadedfile']['name'][0] );
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'] [0], $target_path))
{
echo "The file ". basename( $_FILES['uploadefile']['name'] [0]). " has been uploaded";
}
else {
echo "Sorry, there was a problem uploading your file.";
}
?>
I would also like php to execute this ffmpeg command directly afterwards, but i'm unsure where to insert it.
FFMPEG command
ffmpeg -re -i uploadedfile.name -vcodec copy -f mpegts udp://239.1.1.1:5000
Thanks for all your help.
Kind Regards,
Mark Couto
You need to specify the INDEX KEY of the file:
$_FILES['uploaded']['tmp_name'][0]
$target = $target . basename($_FILES["fileToUpload"]["name"][0]);
if(move_uploaded_file($_FILES['uploaded']['tmp_name'][0], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name'][0]). " has been uploaded";
}
This is the part of code where the problem is
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
$_FILES['uploaded'] should be $_FILES[ 'FileToUpload' ]
Try this
if(move_uploaded_file($_FILES['FileToUpload']['tmp_name'], $target))
<= http://php.net/manual/en/features.file-upload.post-method.php