Reputation: 4834
From the above image i have a video file while i am trying to retrieve the video ->
these issues are coming ->
only for specific files it is happening what could be the possible issue..?
i am appending video data with jquery ajax response:
$("#videoData").append('<video width="75%" class="center-block"
controls autoplay style="max-width: 60em;">
<source style="max-width: 60em;" src="'+path+'" type="video/mp4">
'+response["videoName"]+'</video>');
Inside the path video location will come from start.(http://website.com/uploads/file.mp4)
My html is this:
<div id="videoData"> </div>
My php to store the file is this:
$videoPath = '../uploads/course_videos/'.$coursename;
for ($i = 0; $i < count($_FILES['course_video']['name']); $i++) {
$videofilename = $_FILES["course_video"]["name"][$i];
$videofilename = mysqli_real_escape_string($conn,$videofilename);
$targetVideo = $videoPath ."/". $videofilename;
move_uploaded_file($_FILES["course_video"]["tmp_name"][$i], $targetVideo)
}
All the file is uploading properly in the folder but i don't know why Few videos are not coming
I thought the file may be corrupted but when i download the same file again from server and when i play that in my computer it is working fine.!
Help is appreciated..
Upvotes: 1
Views: 96
Reputation: 13412
If you just directly uploading video files and you don't convert or check them, you might face security issues.
At the same time it's not guaranteed that all uploaded files will play, due to variety of codecs. I'd recommend to perform the check-up on uploaded files to validate them as video and then convert.
The other possible reason why it could be happening, and like you mention, on some files, is that you don't escape URLs properly.
Try using encodeURIComponent(path)
on returned URL.
encodeURIComponent() - The encodeURIComponent() function encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two "surrogate" characters).
Besides, it might be the server-side issue. It's important to escape filenames properly on the server-side as well.
There are dozens of possible problems that can arise on files uploads and playing videos.
Upvotes: 1