I've tried to create a script to upload wmv and mov files to a folder. I can't get the file to upload at all. I'm guessing this is probably a problem in the html but I'm guessing my php code is also wrong since I have never done this before. I've looked everywhere and I'm unable to get it to work. Can anyone help?
Here's the code:
<form action="processsvideo.php" method="POST" name="form" enctype="multipart/form-data">
<label for="file">... or filename (below 50MB)</label>:
<input type="file" name="file" id="file" /><br><br>
<input type="hidden" name="MAX_FILE_SIZE" value="52428800">
<input type="submit" value="Submit" name="submit"></p>
</form>
if((!isset($_FILES['file'])) && ($url == null)){
die('Stop wasting bandwidth!');
}
if((!isset($_FILES['file'])) && ($url != null)){
die('I can\'t do anything with both a file and a url. I only want one video please. Lets not get pathetic.');
}elseif((!isset($_FILES["file"]["name"])) && ($url == null)){
if ($_FILES["file"]["error"] > 0){
die("Error: " . $_FILES["file"]["error"] . "<br />");
}
if($_FILES["file"]["size"] > 52428800){
die ('File size needs to be less than 50MB but hopefully larger than your memory.');
}
if(!(($_FILES["file"]["type"] == "video/quicktime") || ($_FILES["file"]["type"] == "audio/x-ms-wmv"))){
die ('Invalid format. Sorry only wmv and mov files to be used so far.');
}
mysql_connect("localhost","user","pass");
@mysql_select_db(godofgod_p_bb1) or die( "There has been an error in your request. Please try again! Error: Unable to select database.");
$query="SELECT id FROM videos";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$id = $row['id'];
mysql_close();
$result = move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $id . $_FILES["file"]["type"]);
if($result == true){
$url = "upload/" . $id . $_FILES["file"]["type"];
}else{
die('The server is acting stupid again or I have made a mistake. You should try again to see if it works.');
}
}
Thanks!