Reputation: 7173
I am attempting to upload a video file in chunks using PHP. (and we all know how finnicky PHP is with this) Below is my test code:
echo "<form action='' method='post' enctype='multipart/form-data'>";
echo "<input name='video' type='file' />";
echo "<input type='submit' value='UPLOAD' />";
echo "</form>";
if (isset($_POST['video']))
{
$putdata = fopen("php://input", "r");
$fp = fopen("assets/video/test.mp4", "w");
while ($data = fread($putdata, 1024))
{
echo $data;
fwrite($fp, $data);
}
echo "<h1>DONE! (hopefully)</h1>";
fclose($fp);
fclose($putdata);
}
When I echo $data;
, I don't get the contents of the file--instead, I only get video=video.mp4
, with video.mp4
being the name of the file I attempted to upload. What's going on? :( How do I get the actual file's contents?
Upvotes: 6
Views: 5333