My goal is to create a video, and then upload the video onto a file server. I can create the video (which is in the form of a BLOB) and I can convert the BLOB into a file. Next I want to upload that file onto the server. The following html and php code uploads a file to a server. Can I substitute $_FILES["fileToUpload"]["tmp_name"] with the file name that has been created from the BLOB? Is there a simpler way of achieving my goal?
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="upload_.php" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
</body>
</html>
<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
//$target_file = "myFile.jpg";
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["fileToUpload"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
?>
$_FILES['fileToUpload']['tmp_name'];
returns the temporary file name of the file on the server.
$_FILES['fileToUpload']['name'];
returns original name of the uploaded file from yours computer
You can't substitute tmp_name to name on 1st parameter in move_uploaded_file