我的目标是制作视频,然后将视频上传到文件服务器。我可以创建视频(以BLOB的形式),我可以将BLOB转换为文件。接下来我想将该文件上传到服务器上。以下html和php代码将文件上传到服务器。我可以将$ _FILES [“fileToUpload”] [“tmp_name”]替换为从BLOB创建的文件名吗?有没有更简单的方法来实现我的目标?
<!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.";
}
?>
答案 0 :(得分:0)
$_FILES['fileToUpload']['tmp_name'];
返回服务器上文件的临时文件名。
$_FILES['fileToUpload']['name'];
从您的计算机返回上传文件的原始名称
您无法在move_uploaded_file