cisclem Posted September 12, 2009 Share Posted September 12, 2009 Hi - I am trying to create a file link that uses a POST variable as per following code. I am almost there in that if the file is in the root folder it works. The problem is if the file is in a sub-folder i.e. "Data" in this example. When I click on the created link I get a message to say that the page is protected which I know it is not. I first assign the data to the variable $display_block as per following...... $display_block = " <ul> <li><a href=\"Data\"'".$_POST["sel_id"]."'>FILE</a></li> </ul>" ; .....which is then used to populate the html page as follows... <?php echo $display_block; ?> As stated if the file was in the root folder this would work but not in the sub folder "Data". Any help would be appreciated, I have spent hours trying to fix this Thank you Quote Link to comment https://forums.phpfreaks.com/topic/174010-solved-href-problem/ Share on other sites More sharing options...
.josh Posted September 12, 2009 Share Posted September 12, 2009 I think the problem here is that you somehow think the server is lying to you. If you know that the sub-folder is not protected, then why would you get a message saying it is? Did you check the chmod of the directory? .htaccess? edit: also, you're quotes are wrong, which is probably ultimately what's making the protected error happen. Did you look at what it outputs? It outputs for instance: <ul> <li><a href="Data"'123'>FILE</a></li> </ul> Quote Link to comment https://forums.phpfreaks.com/topic/174010-solved-href-problem/#findComment-917292 Share on other sites More sharing options...
cisclem Posted September 12, 2009 Author Share Posted September 12, 2009 I know the Data folder is not protected because other manually created links work - the problem only exists when I try to auto-create the link. I am pretty new to PHP so can you tell me if it is possible to directly open the file without a file link and if so would you be good enough to give me an example using the following details.... Path = \Data\ File = Example.doc Thanks Quote Link to comment https://forums.phpfreaks.com/topic/174010-solved-href-problem/#findComment-917299 Share on other sites More sharing options...
.josh Posted September 12, 2009 Share Posted September 12, 2009 so...did you miss my edit about your quotes being wrong? Quote Link to comment https://forums.phpfreaks.com/topic/174010-solved-href-problem/#findComment-917301 Share on other sites More sharing options...
cisclem Posted September 13, 2009 Author Share Posted September 13, 2009 No - I did not miss your edit about the quotes being wrong - I tried your example and it still does not work - a folder which I know is not protected is being advised as being so. This is why I would like to try using php to directly open a file without the link and see if this still happens Quote Link to comment https://forums.phpfreaks.com/topic/174010-solved-href-problem/#findComment-917503 Share on other sites More sharing options...
.josh Posted September 13, 2009 Share Posted September 13, 2009 I didn't give you an example of how the code should be. I gave you an example of what your code outputs. Your OP code outputs as: [pre] <ul> <li><a href="Data"'123'>FILE</a></li> </ul> [/pre] It needs to output as: [pre] <ul> <li><a href="Data/123">FILE</a></li> </ul> [/pre] Or I guess with a backslash if you're using windows... This is how your quotes should be (change the / to \\ if windows) $display_block = " <ul> <li><a href=\"Data/".$_POST["sel_id"]."\">FILE</a></li> </ul>" ; Quote Link to comment https://forums.phpfreaks.com/topic/174010-solved-href-problem/#findComment-917628 Share on other sites More sharing options...
cisclem Posted September 13, 2009 Author Share Posted September 13, 2009 Great - that did it - many thanks. You made it look simple but I would never have tried putting the slash following Data the other way round. Once again many thanks - you have saved me many more hours of wasted time! Quote Link to comment https://forums.phpfreaks.com/topic/174010-solved-href-problem/#findComment-917640 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.