pieeater
04-07-2007, 04:21 PM
I am trying to make a php script to upload flash only files to my server. The script works apart from when I try to block out any other file types, yet this works in internet explorer but not firefox. Any ideas on how i can modify the script to make it work in both browsers?
Here is the script i am currenty using.
input form
<?php
echo '<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="500000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
Choose a name for the video: <input name="videoname" type="text" /><br />
Enter a description for the video: <input name="description" type="text" /><br />
<input type="submit" value="Upload File" />
<br>
<br>
<br>
<p><a href="http://nositehere.net/uploads/">Show the contents of uploads</a></p>
</form> ';
?>
upload page
<?php
$username = $mybb->user['username'];
$filename = $_FILES['uploadedfile']['name'];
$videoname = $_POST['videoname'];
$description = $_POST['description'];
// Where the file is going to be placed
$target_path = "../uploads/";
/* Add the original filename to our target path.
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$_FILES['uploadedfile']['tmp_name'];
$target_path = "../uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(($_FILES['uploadedfile']['type']) != ('application/x-shockwave-flash') ){
echo "Invalid Filetype! Please Upload a Flash File.";
}
else{
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name'])." has been uploaded";
mysql_query("INSERT INTO uploadedvideos(username, videoname, videodescription, filename) VALUES('".$username."', '".$videoname."', '".$description."', '".$filename."' ) ")
or die(mysql_error());
}
else{
echo "There was an error uploading the file, please try again!";
}
}
?>
Here is the script i am currenty using.
input form
<?php
echo '<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="500000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
Choose a name for the video: <input name="videoname" type="text" /><br />
Enter a description for the video: <input name="description" type="text" /><br />
<input type="submit" value="Upload File" />
<br>
<br>
<br>
<p><a href="http://nositehere.net/uploads/">Show the contents of uploads</a></p>
</form> ';
?>
upload page
<?php
$username = $mybb->user['username'];
$filename = $_FILES['uploadedfile']['name'];
$videoname = $_POST['videoname'];
$description = $_POST['description'];
// Where the file is going to be placed
$target_path = "../uploads/";
/* Add the original filename to our target path.
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$_FILES['uploadedfile']['tmp_name'];
$target_path = "../uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(($_FILES['uploadedfile']['type']) != ('application/x-shockwave-flash') ){
echo "Invalid Filetype! Please Upload a Flash File.";
}
else{
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name'])." has been uploaded";
mysql_query("INSERT INTO uploadedvideos(username, videoname, videodescription, filename) VALUES('".$username."', '".$videoname."', '".$description."', '".$filename."' ) ")
or die(mysql_error());
}
else{
echo "There was an error uploading the file, please try again!";
}
}
?>