I'm trying to make a video uploading system with plupload that also takes a video title and puts it in a database. The video uploader works fine, but as soon as I try to add a separate input field for a title it doesn't work. I tried making a separate button for setting the title, but that didn't work either. Here's the HTML form:
<form id="uploadTitle" action="upload.inc.php" method="POST">
<input type="text" name="title" placeholder="Video Title">
<button class="browse" id="browse" href="javascript:;">Browse</button>
<button class="start-upload" id="start-upload" type="submit" href="javascript:;">Upload</button>
</form>
I have an error handler in my upload.inc.php:
if (empty($_FILES) || $_FILES['file']['error']) {
die('{"OK": 0, "info": "Failed to move uploaded file."}');
}
It throws me this error every time I try to upload a video. I insert the file name / video url into the database just after plupload checks if the file has been uploaded and that works fine, so I modified it to also add the title:
$sql = "INSERT INTO videos(video_url, title)
VALUES('$generatedName', '$title')";
mysqli_query($conn, $sql);
die('{"OK": 1, "info": "Upload successful."}');
Any help is appreciated!
If you are trying to upload a file first need to add the attribute enctype= multipart/form-data to the form,
Then you need an input type file, don't forget the name attribute name='something'