Connecting Tech Pros Worldwide Forums | Help | Site Map

.wmv file downloading

Member
 
Join Date: Nov 2007
Posts: 43
#1: Mar 23 '09
Dear Sir,
i am facing a problem in downloading .wmv file.
while i downloded the .wmv file and then try to open it gives an error that file type is not supported. can any one tell me where is the problem in my php code?

Expand|Select|Wrap|Line Numbers
  1.  
  2. $videoName = "new_Ayman.wmv"; 
  3. $videoDir = "download/tv-interview/"; 
  4.  
  5. $fullPath = $videoDir . $videoName; 
  6.  
  7. header("Content-Type: video/x-ms-wmv"); 
  8. header("Content-disposition: inline; filename={$videoName}"); 
  9. header("Content-length: ". filesize($fullPath)); 
  10. readfile($fullPath); 
  11. exit(); 
  12.  
  13.  
  14.  
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,938
#2: Mar 23 '09

re: .wmv file downloading


I don't see anything obviously wrong your code. Sounds like it's maybe your OS not reading the file correctly.
Member
 
Join Date: Nov 2007
Posts: 43
#3: Mar 23 '09

re: .wmv file downloading


Quote:

Originally Posted by Markus View Post

I don't see anything obviously wrong your code. Sounds like it's maybe your OS not reading the file correctly.

Thanx for your quick response.

Can you tell me what will be problem at OS ?
i checked from different client's pc and all of them are using windows xp. and i am using apache 2.2.8 web server.
in all cases the same problem exist.
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,938
#4: Mar 23 '09

re: .wmv file downloading


Quote:

Originally Posted by farukcse View Post

Thanx for your quick response.

Can you tell me what will be problem at OS ?
i checked from different client's pc and all of them are using windows xp. and i am using apache 2.2.8 web server.
in all cases the same problem exist.

Ok, that more than likely rules out your OS.

Trying setting the mime type (content-type) as 'application/octet-stream'.
Member
 
Join Date: Nov 2007
Posts: 43
#5: Mar 23 '09

re: .wmv file downloading


Now i am using the code like as below.But it remains same problem. the error is like that:
The file you are attempting to play has an extension that does not match the file format.



Expand|Select|Wrap|Line Numbers
  1. videoName = "new_Ayman.wmv"; 
  2. $videoDir = "download/tv-interview/"; 
  3.  
  4. $fullPath = $videoDir . $videoName; 
  5.  
  6. header("Content-Type: application/octet-stream");   
  7. header("Content-Type: video/x-ms-wmv"); 
  8. header("Content-disposition: inline; filename={$videoName}"); 
  9. header("Content-length: ". filesize($fullPath)); 
  10. readfile($fullPath); 
  11. exit();
  12.  
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,938
#6: Mar 23 '09

re: .wmv file downloading


Sounds like the file is maybe corrupt.

Expand|Select|Wrap|Line Numbers
  1. header("Content-Type: application/octet-stream");   
  2. header("Content-disposition: inline; filename={$videoName}"); 
  3. header("Content-length: ". filesize($fullPath)); 
  4. readfile($fullPath); 
  5. exit();
Minus the second content-type header.
Member
 
Join Date: Nov 2007
Posts: 43
#7: Mar 23 '09

re: .wmv file downloading


can you tell me what is reason file to be corrupted?
i tried the following code but it reamins same problem as before.

Expand|Select|Wrap|Line Numbers
  1.  
  2. $videoName = "new_Ayman.wmv"; 
  3. $videoDir = "download/tv-interview/"; 
  4.  
  5. $fullPath = $videoDir . $videoName; 
  6.  
  7. header("Content-Type: application/octet-stream");   
  8.  
  9. header("Content-disposition: inline; filename={$videoName}"); 
  10. header("Content-length: ". filesize($fullPath)); 
  11. readfile($fullPath); 
  12. exit(); 
  13.  
  14.  
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,938
#8: Mar 23 '09

re: .wmv file downloading


Content-disposition may have to be 'attachment' not inline..

Does this happen with any file you try and download?
Member
 
Join Date: Nov 2007
Posts: 43
#9: Mar 24 '09

re: .wmv file downloading


i tried with the code as below. but it remains same problem. this problem is for vedio and audio files. but it does not happend in .doc or jpg files.

[code]
$videoName = "new_Ayman";
$videoDir = "download/tv-interview/";

$fullPath = $videoDir . $videoName;

header("Content-Type: application/octet-stream");
header("Content-disposition: attachment; filename={$videoName}");
header("Content-length: ". filesize($fullPath));
readfile($fullPath);
exit();

[code]
Reply