Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7725289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:54:01+00:00 2026-06-01T04:54:01+00:00

Im trying to display some files in a web page so the user can

  • 0

Im trying to display some files in a web page so the user can download it, i display the files correctly but the link href is not working, instead of download the file, the browser try to display the file in the browser and send :

Not Found

The requested URL /public_html/Factura.pdf was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

$connect = ftp_connect("xxx.org");
$result = ftp_login($connect, "xxx", "xxx");
$a = ftp_nlist($connect, "./public_html/");
foreach($a as $value){
echo '<a href="'.$value.'">'.basename($value).'</a> <BR>';
}

how can i accomplish that?
thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:54:02+00:00Added an answer on June 1, 2026 at 4:54 am

    You can use the basename() function on the path, this will give you the filename:

    foreach($a as $value){
    echo '<a href="'.basename($value).'">'.basename($value).'</a> <BR>';
    }
    

    Edit:
    If the files are local it would be faster to just glob() or opendir() the directory, im assuming your goal is to use this script on a remote server so I would also suggest you include the url to the hosting server.

    $server="xxx.org";
    $connect = ftp_connect($server);
    $result = ftp_login($connect, "xxx", "xxx");
    $a = ftp_nlist($connect, "./public_html/");
    foreach($a as $value){
    echo '<a href="http://'.$server.'/'.basename($value).'">'.basename($value).'</a> <BR>';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to display some message in span. but it is not working.
Right now, what i'm trying to do is display some lists on a page
I have a simple web page that displays some text and images and trying
I'm trying to display some large images with HTML img tags. At the moment
I've been trying to display text using a Quartz context, but no matter what
I am trying to display a list of all files found in the selected
I'm trying to display an array of files in order of date (last modified).
I am creating a table to display on a web page and that table
I am trying to send some message through Websocket to the server. The web
I am trying to display an image file in web browser via the Apache

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.