Jump to content

How to change filename & extension on download


lip9000

Recommended Posts

I have a script that downloads youtube videos, but at the moment it currently downloads it as "video", with no extension. People then have to rename the file to .mp4 so that they can play it. I can't find this anywhere on google, or perhaps I am using the wrong words.

 

I have seen this being done on keepvid, they use a script to change the extension of the download to .mp4

 

http://keepvid.com/save-video.mp4?http%3A%2F%2Fwww.youtube.com%2Fget_video%3Fvideo_id%3DiTBIo1c9xw0%26t%3DOEgsToPDskJd5Ezgva4cxwC76D1fDFOy%26fmt%3D18

 

How would I go about changing the extension like they do, but also rename the actual file as well, so from "video" to "some video name.mp4".

 

Thanks heaps in advance!

 

 

show us the code first then where see if we can use the rename() command

 

My script only gets the youtube URL, and puts it after http://keepvid.com/save-video.mp4?

 

So my script gets http%3A%2F%2Fwww.youtube.com%2Fget_video%3Fvideo_id%3DiTBIo1c9xw0%26t%3DOEgsToPDskJd5Ezgva4cxwC76D1fDFOy%26fmt%3D18

 

Thats all.

 

But I would like to create a script like the one that keepvid uses to rename the download link. I don't think rename() would work because you have to download the file first and then use that function yeh?

 

When you download the video, is it going to a server directory, or is the user getting the file on there desktop.

 

you will have to download the file to a sever directory then rename the file with rename() then

let the user have it.

 

the only way i can think off.

 

let the users select playing videos to download, if the user wants to have that playing video hit download button,

when the user hits download, Your code downloads the file to a server directory, then rename it, and you show the user a link button to confirm, they wanted the file, when button pressed they get the new named, playing video.

You need to understand, that there hundreds off web sites, that also run 3rd party applications with php, and use the exec() command to get there installed application to work.

 

because they got a 3rd party application running with php it looks like there just using php, but there not all them,

downloads are coming from a 3rd party application to let users get the download and renamed to what ever.

 

but becouse you or i, havent got the 3rd party application the only way i can think off php doing it alone explained below.

You need to understand, that there hundreds off web sites, that also run 3rd party applications with php, and use the exec() command to get there installed application to work.

 

because they got a 3rd party application running with php it looks like there just using php, but there not all them,

downloads are coming from a 3rd party application to let users get the download and renamed to what ever.

 

but becouse you or i, havent got the 3rd party application the only way i can think off php doing it alone explained below.

 

Explained below where? Did you miss some code?

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.