Rusty.Metal Posted March 26, 2003 Share Posted March 26, 2003 say i have a form ($image) and the user enters itemname.png how can i get $image to turn into itemname in other words remove the .png? Link to comment Share on other sites More sharing options...
0 Quboid Posted March 26, 2003 Share Posted March 26, 2003 The Pathinfo() function will take a path and get info from it, filename extension and directories. Link to comment Share on other sites More sharing options...
0 Rusty.Metal Posted March 27, 2003 Author Share Posted March 27, 2003 k that helps a litle but how do i get the .png awau in form (textfield name is item) i have entered aaron.png $item = $_POST['item'] $newitem = <some functinn> ($item, .png) echo("$newitem") it would echo aaron Link to comment Share on other sites More sharing options...
0 Quboid Posted March 27, 2003 Share Posted March 27, 2003 What exactly do you want? Do you want the filename without extension? Or do you want everything before the extension, including directories? If you just want the filename do this: $pathnfo = pathinfo($_POST['item']); $newitem = $pathnfo["basename"]; echo("$newitem"); If you want the directory and filename, so this: $pathnfo = pathinfo($_POST['item']); $newitem = $info["dirname"] . "/" . $info["basename"]; echo("$newitem"); Link to comment Share on other sites More sharing options...
0 Rusty.Metal Posted March 27, 2003 Author Share Posted March 27, 2003 view.php?color=red&user=56.png thats what the url will look like, i want it take the user varable $id = $section = $HTTP_GET_VARS['user']; i want to get the 56 out of there... so there is no .png Link to comment Share on other sites More sharing options...
0 Tim Dorr Veteran Posted March 27, 2003 Veteran Share Posted March 27, 2003 actually, you want baseinfo() $item = $_POST['item']; $newitem =basename ($item, ".png"); echo("$newitem"); Link to comment Share on other sites More sharing options...
Question
Rusty.Metal
say i have a form ($image) and the user enters itemname.png
how can i get $image to turn into itemname
in other words remove the .png?
Link to comment
Share on other sites
5 answers to this question
Recommended Posts