which function used to get the file name in php?

Answers were Sorted based on User's Feedback



which function used to get the file name in php?..

Answer / simran

The file name on the browser system
$file_name=$_FILES[$fieldName]['name'];

Is This Answer Correct ?    8 Yes 0 No

which function used to get the file name in php?..

Answer / lakshmi

<?php
$path = "/home/httpd/html/index.php";
$file = basename($path);
$file = basename($path, ".php");
?>

Is This Answer Correct ?    4 Yes 0 No

which function used to get the file name in php?..

Answer / naga

$parts = Explode('/', $_SERVER["SCRIPT_NAME"]);
$currentFile = $parts[count($parts) - 1];

Is This Answer Correct ?    1 Yes 1 No

which function used to get the file name in php?..

Answer / jaimin desai

$file_name=$_FILES[$ControlName]['name'];

Is This Answer Correct ?    0 Yes 0 No

which function used to get the file name in php?..

Answer / nilsoft

Method 1.
$file = trim($_SERVER["SCRIPT_NAME"],'/');
Method 2.
$file =
substr($_SERVER["SCRIPT_NAME"],1,strlen($_SERVER["SCRIPT_NAME"])-1);
Method 3.
$file = str_replace('/','',$_SERVER["SCRIPT_NAME"]);
Method 4.
$file = basename($_SERVER["SCRIPT_NAME"]);

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More PHP Interview Questions

What is the difference between PHP,ASP and JSP?

3 Answers   T3 Softwares,


What is the function of trim?

0 Answers  


write function of the sentence traversal passing the parameter, e.g input:this is input sentence. output:sentence input is this.

1 Answers   HyperQuality,


What u mean by query?

0 Answers  


How do I start a php session?

0 Answers  


What is the default time of cookie in php?

0 Answers  


Which is the correct way to check if a session has already been started ?

0 Answers  


Tell us how can we display the output directly to the browser?

0 Answers  


How to include a file code in different files in php?

0 Answers  


How to find a length of a string in php?

1 Answers  


What is the functionality of md5 function in php?

0 Answers  


What is session management php?

0 Answers  


Categories