我的视频位于桌面上的文件夹中:
/home/john/Desktop/Samples/Vids/small.mp4
如何从上传或其他方式获取此文件路径?
这是我的html表单:
<form class="form-submission" method="post" action="upload.php" enctype= "multipart/form-data">
<input type="file" name="upload[]" id="input-file" multiple required>
<button type="submit" class="btn btn-default no-gradient">Submit</button>
</form>
upload.php的:
<?php
print_r($_FILES);
结果:
Array
(
[upload] => Array
(
[name] => Array
(
[0] => small.mp4
)
[type] => Array
(
[0] => video/mp4
)
[tmp_name] => Array
(
[0] => /tmp/php1KNwas
)
[error] => Array
(
[0] => 0
)
[size] => Array
(
[0] => 383631
)
)
)
但是没有路径信息 - /home/john/Desktop/Samples/Vids/small.mp4
任何想法我怎样才能得到它?
我需要找到视频文件路径,以便将其发送到我的YouTube频道:
// REPLACE this value with the path to the file you are uploading.
$videoPath = "/home/john/Desktop/Samples/Vids/small.mp4";
....
$media->setFileSize(filesize($videoPath));
// Read the media file and upload it chunk by chunk.
$status = false;
$handle = fopen($videoPath, "rb");
while (!$status && !feof($handle)) {
$chunk = fread($handle, $chunkSizeBytes);
$status = $media->nextChunk($chunk);
}
整个视频上传代码均来自google's。