which function used to get the file name in php?
Answers were Sorted based on User's Feedback
Answer / simran
The file name on the browser system
$file_name=$_FILES[$fieldName]['name'];
| Is This Answer Correct ? | 8 Yes | 0 No |
Answer / lakshmi
<?php
$path = "/home/httpd/html/index.php";
$file = basename($path);
$file = basename($path, ".php");
?>
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / naga
$parts = Explode('/', $_SERVER["SCRIPT_NAME"]);
$currentFile = $parts[count($parts) - 1];
| Is This Answer Correct ? | 1 Yes | 1 No |
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 |
How we get ip address of client, previous reference page etc?
Explain the difference between php4 and php5.
What is data structure in php?
How can I maintain the count of how many persons have hit my site?
1 Answers MTOG, Rushmore Consultancy,
How can we encrypt the username and password using PHP?
13 Answers Avaria, HCL, TCS, Xpert,
How a constant is defined in a php script?
How is the comparison of objects done in php?
What is difference between put and post method in http?
How can we get the error when there is a problem to upload a file?
How can we submit form without a submit button?
Tell me whether it is possible to share a single instance of a memcache between multiple php projects?
What and How possible injection in PHP and mysql?