Jump to content

2 Questions


Warptweet

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.