Mozilla Firefox does not understand files with spaces

I have files that I upload to a website that may contain spaces, such as:

file name 1.wav 

It usually displays when downloading, but when I try to download a file from Chrome and Firefox, I get the following results:

  Chrome downloaded: file name 1.wav (perfect) firefox downloaded: file (bad) 

name 1.wav removed from name. Are there any specific functions in PHP that will fix this problem in firefox?

CODE:

  <?= str_replace(array("'",'"'), array("&#39;","&quot;"), stripslashes($sFileTitle)) ?>', '<?=$f['fileExtension']?>' 

This is what appears when I check the element on the anchor tag where the file should be loaded:

  <a title="file name 1.wav" fileid="254" class="docLink">file name 1.wav</a> 

I am using jQuery to redirect to the correct path.

FIX:

Adding urlencode ($ file) is fixed, but a new problem has occurred. Now file named

  file name 1.wav 

turns on at boot time:

  file+name+1.wav 

Is it possible to replace + space after loading? urldecode did not work

Decision:

if someone else having the same problem is how I fixed it:

instead of urlencode / decode I just did this:

  '"' . stripslashes($file) . '"' 

and he fixed it

+4
source share
1 answer
 <?php header("Content-Disposition: attachment; filename=\"$filename\""); ?> 
+3
source

Source: https://habr.com/ru/post/1437417/


All Articles