php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74641 Escaping a digit on directory name
Submitted: 2017-05-24 00:21 UTC Modified: 2017-05-24 11:35 UTC
From: falzone at outlook dot com Assigned:
Status: Not a bug Package: *Directory/Filesystem functions
PHP Version: Irrelevant OS: Windows 10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: falzone at outlook dot com
New email:
PHP Version: OS:

 

 [2017-05-24 00:21 UTC] falzone at outlook dot com
Description:
------------
---
From manual page: http://www.php.net/function.move-uploaded-file
---


Test script:
---------------
move_uploaded_file($_FILES["file"]["tmp_name"], "G:\WEB Servers\UwAmp\www\3_KachiVersiaPurva\uploads\\" . $_FILES["file"]["name"]);

Expected result:
----------------
I expect to upload a file in this directory. When i escape it like this: "G:\WEB Servers\UwAmp\www\\3_KachiVersiaPurva\uploads\\" it's working like a charm. Why i should escape digit (3 in my case). It isn't backslash or so

Actual result:
--------------
Warning: move_uploaded_file(G:\WEB Servers\UwAmp\www_KachiVersiaPurva\uploads\05.11.2016.peak_temperature.gif): failed to open stream: No such file or directory in G:\WEB Servers\UwAmp\www\3_KachiVersiaPurva\image.php on line 32

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-05-24 11:35 UTC] ab@php.net
-Status: Open +Status: Not a bug
 [2017-05-24 11:35 UTC] ab@php.net
Thanks for the report. Literals in double quotes extrapolate escape sequences, please consult the manual.

Thanks.
 [2017-05-24 11:42 UTC] spam2 at rhsoft dot net
or to explain it better:

"\\3" don't escape the digit

it escapes the backslash itself and it needs to be escaped within ""

you can use even on windows a normal / for a path
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC