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) Quote Link to comment 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. Quote Link to comment 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.