$filename = "Sara & I.mp3"; if (file_exists($filename)) { ... }
If the file name has " &", PHP does not return true forfile_exists
&
file_exists
How can I escape the " &" in $ filename for file_existsto work?
Already I tried urlecode(), urlrawencode(), htmlentities()and escaped '&' with a backslash (\ &) ... no go
urlecode()
urlrawencode()
htmlentities()
ps. it's on a linux system running redhat5
early
It seems to me that the script is working for me.
Make sure the file you are checking is in the directory where your script is running.
getcwd(), , script.
. script /scripts/ script.php script my/other/scripts/index.php, script my/other/scripts, my/scripts,
? , A-Z, 0-9 _ - , .pdf, charachters. _.
TYPO3, CMS PHP, , :
$fileName = preg_replace('/[^.[:alnum:]_-]/','_',trim($fileName)); // converting all on alphanumeric chars to _ $fileName = preg_replace('/\.*$/','',$fileName); // removing dot . after file extension
, foo&.pdf. foo.pdf
foo&.pdf.
foo.pdf
, , ? - \& , , escape- unicode ( ;-)?
, GET, script.php?file=this & that.mp3
script.php?file=this & that.mp3
, , . second: urlencode . char & %26.
urlencode
%26
script : script.php?file=this%20%26%20that.mp3 (%20 )
script.php?file=this%20%26%20that.mp3
%20
GET, that.mp3, . & GET
that.mp3
: ? phps unlink? exec rm ? ( ). , escapeshellarg. , (afaik, )
unlink
exec
rm
escapeshellarg
- script? .
, glob() , ? ? , glob() _exists() ?
Source: https://habr.com/ru/post/1720366/More articles:How to view the resulting html controller in debugging using ASP.NET MVC? - asp.net-mvcASP.NET registers a control from an external dll on a page - c #Network programming: SOAP and DIY sorted using XML library? - c ++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1720364/tutorial-for-using-javascript-on-a-desktop&usg=ALkJrhioQs-4wGaeLsL3Rw8fq0McrXHgcQComboBoxItem for full width ComboBox when using SelectedIndex or a navigation keyboard? - wpfImage Scaling NSToolbarItem - objective-cDeploy SQL Server CE with my Windows Mobile application - windows-mobileExtract audio from FLV and inject into MP3 - c #Visual Studio - Vs Web Project Website - visual-studioImplementing business logic in a 3-tier architecture - phpAll Articles