Why wont my mp4 (video) file display on the webpage?

Hi. As you know from my previous questions, I’m developing a PHP upload/file system. I successfully
upload files to the server and the path to the database for fetching. Now, i’ve stumbled upon a catching
conflict. When i upload audio and image files, it successfully uploads and displays on that person’s profile page (content.php). But when someone tries to upload a simple mp4 video file, it uploads to the server and database, like expected, but… it shows the not found error(the white square with the red “x” inside of it). Right on the center of where the video is supposed to be. The pages pick up all image and audio files, but why not video files? Anyway, here’s my code for content.php:

[php]

G.B. -- Content <?php session_start $userid = $_GET["id"]; $directory = $_GET["Directory"]; $type = $_GET["Type"]; if ($type == "image/jpeg" || $type == "image/png" || $type == "image/pjpeg") //if type is an image type... { ?>

" height = "500" width = "600" />

<?php } if ($type == "audio/mpeg") //If type is an mp3 file... { ?>

<?php } if ($type == "video/mp4") //if type is a video type { ?>

<?php } ?>

[/php]

by the way, all files are stored in my root folder, then in another folder called uploads. belevie me it uploads to “uploads/” folder and the database. but why does only that one tag above give me a display error? Remember, everything else is found on the server and displayed successfully, but why not this?

Thanks. and sorry for all the annoying posts

Still accepting all answers

Well I don’t how you would expect help when we don’t know the contents of your get data, but right off the bat I see an error.

[php]session_start [/php]is suppose to be [php]session_start()[/php]

Also why are you not outputting all of the html? You realize

[php]



	</p>[/php]

is suppose to be

[php]echo "



	</p>";[/php]

right?

Would one of these coding errors be the reason why the video shows a white square with red cross?

Anyway, the $directory = $_GET[“Directory”]. And the $_GET[“Directory”]'s value is the filename of the video
being displayed. for example, $_GET[“Directory”]'s value is 48356Wildlifesafari.mp4

And the $type=$_GET[“Type”]. $_GET[“type”] is simply each mime type of each file.

for example, audio/mpeg…

Thanks

Those are my $_GET values. Hopefully from there you guys can find my error.

Thanks

Ok where to start… Your script has several errors. First you do not need the header HTML garbage at the top just echo the title line in the php script. Also your repetitive if statements are good but not the “proper way” to do the if then else structure. Your unnecessarily exiting out of the php file to write your html code and your spacing is just to outrageous… The good news is you had the basic idea down right you were just missing the finishing touches. Here is a completed piece of code that plays video.

[php]<?php
session_start();

echo “G.B. – Content”;

$userid = $_GET[“id”];
$directory = $_GET[“Directory”];
$type = $_GET[“Type”];

//if type is an image type…
if ($type == “image/jpeg” || $type == “image/png” || $type == “image/pjpeg”) {
echo"

<img src = “http://68.192.202.0:87/uploads/$directory” height = “500” width = “600” />

";
}

//If type is an mp3 file…
elseif ($type == “audio/mpeg”) {
echo "

<audio controls=“controls”><source src=“http://68.192.202.0:87/uploads/$directory” type="$type" />

";
}

//if type is a video type
elseif ($type == “video/mp4”) {
echo "

<video preload=“auto” width=“320” height=“240” controls=“controls”><source src=“uploads/$directory” type="$type" />

"; #
}

?>[/php]

If you video is not playing with this code the issue is the information your passing to your variables. If you hard code the variables to a single file you will see this works. Double check the values of the variables your passing.

I tried uploading video/mp4 with your code:

[php]
elseif ($type == “video/mp4”) { echo "

<video preload=“auto” width=“320” height=“240” controls=“controls”><source src=“uploads/$directory” type="$type" />

"; # }
[/php]

And the video still gives me the error with the white square and red x inside of it. I was away for a few days and i couldnt respond before. but any suggestions would be much appreciated.

UPDATE:::: I have some news: since when i open up the uploads foler on my server in the brower, it will give me a list of all my file (the directory) and for some reason, it gives a not found 404 error when i click on the mp4 videoes. its like all files but the mp4 files can be found. why wont the mp4 files be recognized or found? thanks

Permissions possibly?

Well all I know is the browser has no problem finding picture and audio files, but when it comes to my mp4 file, it that error with the white square and red x inside of it. I even wrote the path in the erver to that mp4
file in the address bar, and it gives the 404 error NOT FOUND. how do i see if it is a permissions problem?
thanks

Have a look through your web file viewer or via your FTP client it should say in their.

I have not seen your previous posts, so this may have already been addressed, but have you verified that your php.ini file is set to allow large enough files? This could explain the video files not being uploaded like the others.

You can add the following to your php code to display the relevant configuration info:[php]phpinfo(INFO_CONFIGURATION);[/php]Among other possibilities, check the upload_max_filesize and post_max_size. Make sure that post_max_size is larger than upload_max_filesize and the upload_max_filesize is at least as large as the largest file you would like to allow.

Yes, the uploaded video file uploads to the server file “uploads”. When i type in my ip and then the path
on the server, it gives a 404 NOT FOUND message. so Its on the server but the path wont display the video
on the internet browser (ie9). I’m using the HTML5 tag to display them each, but everytime i load
a page where the video is supposed to be, it shows that little white square with a red x inside of it. It’s most likely not finding the files on the server, but the files are acually there, it just wont accept them. Why is this?

Thanks

In that case you are best contacting your web hosting provider.

Well I’m just in the middle of moving my localhost server, to a hosted cloud server. So since the problem was on my computer, how could I avoid this problem on my new server? Thanks

That could of been a issue. Upload it and get back to us.

Ok i’ll try this all again on my cloud server and get back to you guys. Thanks so much for everything!

Sponsor our Newsletter | Privacy Policy | Terms of Service