user3386779
user3386779

Reputation: 7175

Anchor tag redirects to wrong path

I want to redirect to using anchor tag. But I path get changed while redirecting.

for eg.my path is 'company/limit -l.doc'

it redirects as

'company/limit+-l.doc'.

File is uploaded as company/limit -l.doc in folder. It adds '+' in whitespace.

 $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
 $url='resume/'.$_FILES['resume']['name'];
 $url1="//sample.com/domain/".$url;
 $body.='resume :<a href="'.$url1.'" download>Download</a> <br>';

Upvotes: 0

Views: 155

Answers (1)

sjm
sjm

Reputation: 5468

You will need to URL Encode that document name because it has a space http://php.net/manual/en/function.rawurlencode.php which will convert "limit -l.doc" into "limit%20-l.doc"

$body.='resume :<a href="//sample.com/domain/company/'.'.rawurlencode($url).'" download>Download</a> <br>';

the slashes '/' will get encoded by rawurlencode too so you will need to keep the folder structure out of the URL encoding

http://sandbox.onlinephpfunctions.com/code/80b9097b5239f924184a5b074bd0b7225261abcc

Upvotes: 1

Related Questions