Hướng dẫn dùng fakepath meaning trong PHP

I am uploading an image via AJAX and the image uploads ok but the image´s name I am saving on database is like this:

c:\fakepath\2_3.png

How can I get rid of this "c:\fakepath\" before the image´s name with PHP.

Thanks

asked Dec 2, 2011 at 15:34

3

The back slash is tripping basename up.

Here is the solution:

";

$file = str_replace( "\\", '/', $file );

echo basename( $file ) . "
";

output:

c:\fakepath\blah.jpg
blah.jpg

answered Dec 2, 2011 at 16:59

Tim GTim G

1,79411 silver badges25 bronze badges

0

$filename = basename("c:\fakepath\2_3.png");
echo $filename; //2_3.png

answered Dec 2, 2011 at 15:36

PatéPaté

1,8942 gold badges21 silver badges32 bronze badges

0

Just use basename() for that.

answered Dec 2, 2011 at 15:35

Hướng dẫn dùng fakepath meaning trong PHP

Till HelgeTill Helge

9,0972 gold badges38 silver badges56 bronze badges

0

Here's the correct one which I have tried and tested. And it works!!


Hướng dẫn dùng fakepath meaning trong PHP

answered Oct 17, 2017 at 6:28

Not the answer you're looking for? Browse other questions tagged php or ask your own question.