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
https://forums.phpfreaks.com/topic/40093-2-questions/#findComment-194005
Share on other sites

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.