Warptweet Posted February 26, 2007 Share Posted February 26, 2007 A) When a file is uploaded, how can I change it's extension to .wtw, but keep it's filename? B) How can I do the <embed src="linktosource">, EXCEPT, open it as a .swf file instead of it's normal extension? (the normal extension is .wtw) Link to comment https://forums.phpfreaks.com/topic/40093-2-questions/ Share on other sites More sharing options...
severndigital Posted February 26, 2007 Share Posted February 26, 2007 1. capture filename 2. explode filename 3. change extention 4. rewrite filename there are several ways to simplify this code, but i broke it out as specific as possible to explain it. <? /* get file name I assumed it was being uploaded. if not, you can pull the filename from a database as well */ $file = $_FILES['form.fieldname']['name']; //explode at the dot $var = explode(".",$file); /* This will put the file name into an array that contains the information before and after the dot */ //get the filename $filename = $var[0];//this will grab the info BEFORE the dot. //now change the ext $new_ext = 'wtw'; now piece it back together $filename = '' . $filename . '.' . $new_ext''; //do what ever you want with the file after this. ?> that should do what you need. you can do the same thing when reopening the file just change the new ext to whatever you need it to be. personally i would create two functions 1. changes name to .wtw 2. changes name to .swf for display and writes a temporary file to view. Link to comment https://forums.phpfreaks.com/topic/40093-2-questions/#findComment-194005 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.