Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/174010-solved-href-problem/
Share on other sites

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>

 

 

Link to comment
https://forums.phpfreaks.com/topic/174010-solved-href-problem/#findComment-917292
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/174010-solved-href-problem/#findComment-917299
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/174010-solved-href-problem/#findComment-917503
Share on other sites

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>"
; 

 

Link to comment
https://forums.phpfreaks.com/topic/174010-solved-href-problem/#findComment-917628
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.