0

I've PHP code like that

<form action="" method="POST">
<input type="file" name="asdf">
<input type="submit" name="submit" value="submit">
</form>

<?php
$file = $_POST['asdf'];
$file2 = realpath($file);
$file3 = str_replace('\\','/',$file2);
echo $file3;
?>

I'm stuck at when I using IE to run this script ex I choose file = 'D:\myfolder\folder1\filename.txt' the code isn't going error. But when I using Firefox or Chrome, there are nothing giving me result.

Govind Samrow
  • 9,981
  • 13
  • 53
  • 90
user8124226
  • 104
  • 12
  • 2
    Because you are not allowed to access the file system like that – John Conde Jul 26 '17 at 11:17
  • Check http://php.net/manual/en/function.realpath.php. – Virb Jul 26 '17 at 11:19
  • Add [error reporting](http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php/845025#845025) to the top of your file(s) _while testing_ right after your opening PHP tag for example ` – RiggsFolly Jul 26 '17 at 11:21
  • Hi @RiggsFolly, I've try to add the display_errors but result not giving me an error report. here my script 2. ". $filee; ?> in the IE giving me results : 1. C:/Users/40702505/Documents/asd.txt 2. C:\Users\40702505\Documents\asd.txt but Chrome just blank – user8124226 Jul 26 '17 at 11:56
  • @JohnConde in IE the code is running well, but i still not get the core why at chrome & firefox are show me nothing – user8124226 Jul 26 '17 at 12:39
  • The PHP code runs on the server, not in IE, Firefox or Chrome. It produces the same result, no matter what browser do you use to see it. If its output looks different in different browsers it means the output is invalid HTML; each browser is allowed to fix it as it thinks it's better (but none of them could read your mind, though). – axiac Jul 26 '17 at 13:07

0 Answers0