Jump to content

Wierd file uploading problem


uknowho008

Recommended Posts

im using php to upload videos in wmv and mpg format to my webserver.  it all seems to work fine until i upload certain wmv's. some work and some dont. for some reason for certain wmv's its as if there was no post at all. i tried echoing the file type just to see what would come up and for the videos that work is would come up with video/ms-wmv or whatever but for the ones that dont seem to work it doesnt do anything.  it doesnt even seem to post anything through the html form. does anybody have a clue as to why this could be happening? im completely stumped.
Link to comment
https://forums.phpfreaks.com/topic/33422-wierd-file-uploading-problem/
Share on other sites

its kinda difficult because there in functions and its kind of a mess. but heres what i can do.

function VideoUploadForm() {
$Page = $_SERVER["REQUEST_URI"];
echo <<<HTML
<table>
  <tr><th>Videos</th></tr>
  <tr><td><form method="post" action="$Page" enctype="multipart/form-data">
  Title: <input type="text" name="Title"></td></tr>
  <tr><td>Downloadable: Yes <input type="radio" name="Down" value="1"> No <input type="radio" name="Down" value="0" checked></td></tr>
  <tr><td>
HTML;
SelectBox(Interests, Title, "", "WHERE MediaAllowed=1");
echo <<<HTML
  </td></tr>
  <tr><td><textarea class="about_me" name="Body"></textarea></td></tr>
  <tr><td><input class="input" type="file" name="File" /></td></tr>
  <tr><td><center><input type="submit" name="SubmitVideo" value="Submit" /></center></form></td></tr>
</table>
HTML;
}


goes to the same page where this is

if(IsSet($_POST["SubmitVideo"])) {
SubmitVideo();
} else {
VideoUploadForm();
}


function SubmitVideo() {
$Title = PostClean("Title");
$Cat = PostClean("InterestsTitle");
$Body = PostClean("Body");
$Down = PostClean("Down");
echo $_FILES["File"]["type"];
/*
if(!$Title OR !$Cat OR !$Body OR !$_FILES["File"]["type"]) {
  echo "Your missing some information.";
  VideoUploadForm();
} elseif($_FILES["File"]["type"] == ("video/mpeg" OR "video/mpg" OR "video/mpe" OR "video/x-msvideo" OR "video/avi" OR "video/x-ms-wmv")) {

  $Me = $_SESSION["Me"];
  $Date = mktime();
  $Rand = Rand();
  $url = "$Me" . "n" . "$Rand" . "n" . $_FILES['File']['name'];

  copy ($_FILES['File']['tmp_name'], "post_media/$url")
  or die ("Could not copy");

  $insert_sql = "
  INSERT INTO Posts(Type, UserID, Category, Title, Body, Date)
  VALUES ('5', '$Me', '$Cat', '$Title', '$Body', '$Date')
  ";
  mysql_query($insert_sql) or die("Bad query");

  $PostID = mysql_insert_id();
  $insert_sql = "
  INSERT INTO PostMedia(PostID, Type, URL, Download)
  VALUES ('$PostID', '5', '$url', '$Down')
  ";
  mysql_query($insert_sql) or die("Bad query");
 
  redirect("videos.php?ID=$PostID");
} else {
  echo "Videos must be in mpeg or wmv format";
  VideoUploadForm();
}
*/
}



the code for video upload is in quotes because i added the echo file type to see what it is outputing and it just sends me back to the upload form.


thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.