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 1034889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:27:44+00:00 2026-05-16T14:27:44+00:00

It should be easy to do, but I have no clue even after days

  • 0

It should be easy to do, but I have no clue even after days of googling.

I’ve create a simple web form using PHP which allows users to upload image files to server, and the information e.g. date, filename (unique, automatically renamed when uploaded), etc. is input into MySQL table create.

Can I know how to create a link on the ‘unique filename’ uploaded in MySQL field when displayed, so when user clicked, it will automatically open the server stored file per the unique filename?

Appreciate if anyone can help me on this. Thanks in advance.

  • 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-05-16T14:27:45+00:00Added an answer on May 16, 2026 at 2:27 pm

    Assuming your table contains fields id, type (MIME type) and data (binary data), this is a PHP script for that:

    <?php //dispimg.php
    //example usage: dispimage.php?id=123
    $my = new MySQLi('localhost', 'user', 'pass', 'db');
    $sql = sprintf('SELECT type, data FROM table WHERE id="%s" LIMIT 1', $my->real_escape_string($id));
    if(!$queryResult=$my->query($sql)){
       //query failed, log mysqli_error() somewhere
    }
    elseif(!$queryResult->num_rows){
       header('HTTP/1.1 404 Not Found');
       echo 'File not found';
    }
    else($res=$queryResult->fetch_assoc()){
       //optionally, use application/octet-stream instead of a field from database
       header('Content-Type: '.$res['type']));
       // uncomment following line if you want to present the file as download
       //header('Content-Disposition: attachment;filename=download');
       echo $res['data'];
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seemed like it should be easy, but I have had trouble getting it
It seems this should be easy but I'm having a lot of difficulty using
This should be easy but I have just started toying with matplotlib and python.
Seems like in Perl this should be easy or a module, but I have
This should be relatively easy to do, but after several hours straight programming my
Should be easy but google couldn't give me a straight answer. I have an
Ok this should be easy but I can NOT figure it out. I have
I feel like this one should be easy but after numerous searches and attempts
This should be easy but for some reason it will not work. I have
This should be easy but it's not working. I have a WPF combobox bound

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.