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

How can we convert the time zones using PHP?

1 Answers  


How to remove an empty directory?

0 Answers  


How will you calculate days between two dates in PHP?

0 Answers  


what is the current salary package in India for a PHP & MySQL programmer who has 3 years experience

127 Answers   ABC, BLG Logistics, Google, HCL, IBM, Infosys, People Group, PHP, Torque Infotech, V Angelz Technologies, Yahoo,


What is the use of trim function in php?

0 Answers  






What does the array operator '===' means?

0 Answers  


What is php oop?

0 Answers  


How to find the index of an element in an array php?

0 Answers  


How do you pass a variable by value in php?

0 Answers  


What is the difference between query and inquiry?

0 Answers  


Explain me what is the goto statement useful for?

0 Answers  


What are some new features introduced in php7?

0 Answers  


Categories