This topic is locked

split the filename

4/6/2007 7:26:18 AM
PHPRunner General questions
samsp author

hi forum,
one question for file uploading. i have a databasetable for images with two fields: 1. filename and 2. type. if i load the image up i have to split the imagename. example: name of file is: "image1.jpg" and i like to split in: field1: "image1" and in field2: ".jpg". To show the pictures i have accumulatet it like this: "open_win('../img/".$data["fname"].$data["type"]". somebody has an idea?
greetings from spain
sam

samsp author 4/6/2007

hi everybody,
ok, to make it short i split that like:
$_FILES['Datei']['type'] = strtolower(substr($_FILES['Datei']['name'],-4));

$_FILES['Datei']['name'] = substr_replace($_FILES['Datei']['name'],'', -4);

$SQL = "INSERT INTO images ";
but i like to know in which files i must place this code.
sam

samsp author 4/7/2007

hi,
in the _add.php there are this lines:
$value = postvalue("value_fname");

$type=postvalue("type_fname");

if (in_assoc_array("type_fname",$_POST) || in_assoc_array("value_fname",$_POST) || in_assoc_array("value_fname",$_FILES))

{

$value=prepare_for_db("fname",$value,$type);

}

else

$value=false;

if(!($value===false))

{

$avalues["fname"]=$value;

}
how can i bild in the splitinglines

samsp author 4/9/2007

hi,
is there no anser, or is the question to inexact?
samsp

J
Jane 4/10/2007

Sam,
to split image name use Before record added or Before record updated event on the Events tab.

Here is a sample:

$values["ImageName"]= substr($values["FullImageName"],0,strlen($values["FullImageName"])-4);

$values["Type"] = strtolower(substr($values["FullImageName"],-4));

samsp author 4/10/2007

thank you jane,
sometimes the things can be so easy.
greetings
sam