I saved the link refrence in Databse like /PEDB/SupportDoc/5/PRFF or0444.pdf
and used <a href=".$r1[10]." target=_blank>View</a> to show the documents but when I click on view its not showing document because link break where space put in and show blank in explorer like /PEDB/SupportDoc/5/PRFF

Recommended Answers

All 14 Replies

I think this is what you are looking for

$a = "/PEDB/SupportDoc/5/PRFF or0444.pdf";
 $b = urlencode($a);
 echo "<a href='{$b}'>Click</a>";

I think this is what you are looking for

$a = "/PEDB/SupportDoc/5/PRFF or0444.pdf";
 $b = urlencode($a);
 echo "<a href='{$b}'>Click</a>";

When i did this it shows
/PEDB/%2FPEDB%2FSupportDoc%2F5%2FPRFFor0444.pdf

Any other idea?

Please guide me in this issue...

I think its not because of space.
Your href link must start with http:// to work in browser.
When you click on link what is url shown in browser?

Member Avatar for diafol

You don't have to have http:// in the href.

The space shouldn't be there. Filenames should not have spaces in them. I'd go at it to change them - change them from space to underscore or similar.

I have checked with test name.txt and it works fine in my browser.
and if i give only google.com in my href it won't work.

You don't have to have http:// in the href.

The space shouldn't be there. Filenames should not have spaces in them. I'd go at it to change them - change them from space to underscore or similar.

I think its not because of space.
Your href link must start with http:// to work in browser.
When you click on link what is url shown in browser?

My link starts with http:// then local ip then this part /PEDB

as PEDB in root so I do not required to write Http , browser adds automatically

You don't have to have http:// in the href.

The space shouldn't be there. Filenames should not have spaces in them. I'd go at it to change them - change them from space to underscore or similar.

any encoding Technique will work ????

Member Avatar for diafol

If you're accessing files in your own domain you do not need 'http://' in the href, you can use absolute or relative references. If you're trying to access files outside your serves, yes you will need some flavour of http://, https:// etc.

You can have spaces in filenames, but be aware that this can cause all sorts of problems. The easiest thing to do is to convert spaces to underscores. Encode if you want, but I think it's best to apply sensible filenames in the first instance. If these files are not yours and you cannot change them (e.e. not your domain), you won't be able to do this though. Having said that, I can't remember the last time I downloaded a file with a silly symbol (space, etc) in it.

href is not an issue . its work anywhere.

Have you tried quotes around href

<a href='".$r1[10]."' target=_blank>View</a>

<a href=".$r1[10]." target=_blank>View</a> It's just like a circulate.

Why waste all the time while you can solve the problem by removing space? I cannot see what is so peculiar about that space. as Ardav said, remove it and you will be fine!

I convert the file names according to my needs and save in DB without spaces.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.