Mancent Posted November 10, 2012 Share Posted November 10, 2012 (edited) Say you have this url link as http://wiistream.com/users/100001957015772/sounds/028d18dfa174315ef5dca7c006b815fd.wss and you want to make a download button to download this link as a file; and the file name would be the name of the file with the correct ext. so it would be somthing like this Eminem - Mockingbird.mp3 how could I do that. I can select all the data like the name, and the file, and make the button, to call the script, but how do i do it so it's a download, and also change the data back to what it was. from 028d18dfa174315ef5dca7c006b815fd.wss to Eminem - Mockingbird.mp3 so here is the mysql table data that i can collect 100002957030150 Eminem - Mockingbird http://wiistream.com/users/100001957015772/sounds/3fdc92b5c44a29d9d24f71e791663a3f.wss 1 1 UserId,SongName,SongUrl,count,protection so i can collect the songname and the other data and the location of the file with the link, Edited November 10, 2012 by Mancent Quote Link to comment https://forums.phpfreaks.com/topic/270527-is-there-a-way-to-change-a-link/ Share on other sites More sharing options...
Pikachu2000 Posted November 10, 2012 Share Posted November 10, 2012 It isn't really clear what data you have and don't have, but if you don't already have the song name, you can't get it from the hash value. Hashes are one-way. If that isn't your question, clarify, please. Quote Link to comment https://forums.phpfreaks.com/topic/270527-is-there-a-way-to-change-a-link/#findComment-1391439 Share on other sites More sharing options...
Mancent Posted November 10, 2012 Author Share Posted November 10, 2012 (edited) I basically need a script that will download a URL link instead of going to the link, it works as a download. once i understand that part of the code. Ill have the download part that downloads this url That's the mp3 http://wiistream.com/users/100001957015772/sounds/3fdc92b5c44a29d9d24f71e791663a3f.wss Then I guess We would strip the http://wiistream.com/users/100001957015772/sounds/ and only keep the file name itself 3fdc92b5c44a29d9d24f71e791663a3f.wss or maybe not. and i basically want to rename this file 3fdc92b5c44a29d9d24f71e791663a3f.wss before the download starts it has to convert this 3fdc92b5c44a29d9d24f71e791663a3f.wss from this 3fdc92b5c44a29d9d24f71e791663a3f.wss to the song name that will be post as a var to the script. and this 3fdc92b5c44a29d9d24f71e791663a3f.wss will turn into Eminem - Mockingbird.mp3 and download. is that possible? Edited November 10, 2012 by Mancent Quote Link to comment https://forums.phpfreaks.com/topic/270527-is-there-a-way-to-change-a-link/#findComment-1391458 Share on other sites More sharing options...
Mancent Posted November 10, 2012 Author Share Posted November 10, 2012 (edited) see this is my uploader script and i want to convert it back to the name of the song. $filetempname=$_FILES['Filedata']['tmp_name']; $ext =".wss"; $filename=md5(md5($filetempname)).$ext; move_uploaded_file($filetempname,$filepath.$filename); but then when i download it it I want it to go back to $filename ='3fdc92b5c44a29d9d24f71e791663a3f.wss'; $SongName='Eminem - Mockingbird'; $ext =".mp3"; $filename=$SongName.$ext; and some way to download it. I don't know how to do that. so is there some way to make it do something like this. download as $Temp_FileName(http://wiistream.com/users/100001957015772/sounds/3fdc92b5c44a29d9d24f71e791663as3f.wss); Convert as Filename http://wiistream.com/users/100001957015772/sounds/Eminem - Mockingbird.mp3 Edited November 10, 2012 by Mancent Quote Link to comment https://forums.phpfreaks.com/topic/270527-is-there-a-way-to-change-a-link/#findComment-1391459 Share on other sites More sharing options...
Manixat Posted November 10, 2012 Share Posted November 10, 2012 When a file is being downloaded you basically cannot do much. A file will be downloaded with the same name that it has on the server, which leads to the question - why bother hashing the name of the file? Quote Link to comment https://forums.phpfreaks.com/topic/270527-is-there-a-way-to-change-a-link/#findComment-1391472 Share on other sites More sharing options...
MDCode Posted November 10, 2012 Share Posted November 10, 2012 (edited) $_FILES["Filedata"]["name"] in your case, will give you the name of the file uploaded Edited November 10, 2012 by SocialCloud Quote Link to comment https://forums.phpfreaks.com/topic/270527-is-there-a-way-to-change-a-link/#findComment-1391513 Share on other sites More sharing options...
DavidAM Posted November 11, 2012 Share Posted November 11, 2012 When a file is being downloaded you basically cannot do much. A file will be downloaded with the same name that it has on the server, which leads to the question - why bother hashing the name of the file? Actually, you can suggest a filename using a header: header('Content-Disposition: attachment; filename="suggestFilename.ext"'); I say suggest, because the user can always change it in the "Save As" dialog box. Quote Link to comment https://forums.phpfreaks.com/topic/270527-is-there-a-way-to-change-a-link/#findComment-1391647 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.