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

  • SEARCH
  • Home
  • 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 9220011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:14:56+00:00 2026-06-18T03:14:56+00:00

I’m making a system for adding files to a database. I use a form:

  • 0

I’m making a system for adding files to a database. I use a form:

<form action="insert.php" method="post" enctype="multipart/form-data">
Fil: <input type="file" name="file" id="file">
Titel: <input type="text" name="titel" /><br />
Längd (min): <input type="text" name="langd" /><br />
Medverkande: <input type="text" name="medverkande" /><br />
Reporter: <input type="text" name="reporter" /><br />
Fotograf: <input type="text" name="fotograf" /><br />
Sökord: <input type="text" name="sokord" /><br />
<input type="submit" />
</form>

The code in insert.php:

<?php
$con = mysql_connect("database","user","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("165666-kltvplay", $con);

$filnamn = $_FILES["file"]["name"] ;
$sql="INSERT INTO Blad1 (ProgramID, Titel, Langd, Medverkande, Reporter, Fotograf, Sokord)
VALUES
('$filnamn','$_POST[titel]','$_POST[langd]','$_POST[medverkande]','$_POST[reporter]','$_POST[fotograf]','$_POST[sokord]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "En ny film inlagd: <br> ";
echo $filnamn;

mysql_close($con);
?>

But when I add the file it seems to be uploading the whole file because there is a % counter in my browser and it’s taking a loooong time to complete(the files are qute big). I just want the name of the file inserted into the database (and that is working) but not to upload the whole file.

And is it possible to add just the name and not the file exetension?

  • 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-18T03:14:58+00:00Added an answer on June 18, 2026 at 3:14 am

    You’ll have to do some JavaScript magic. Once the user has selected a file, you can read the file name:

    var fileName = document.getElementById('file').value;
    

    Then put that value into a hidden input field (that is inside your form):

    document.getElementById('hidden-filename').value = fileName;
    

    Then hook into the form’s submit event and remove the file input so it won`t get submitted.

    On the server you read the value of the hidden-filename (or whatever the name) and insert it into the DB.

    Be warned though that not all browsers will return the actual file path. The name of the file will be correct, but the path may not be.

    Also note that you won’t be able to do anything with this file then (on the server or on the client).

    AS for the last question you had (no extension), look at this: PHP, get file name without file extension

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I'm trying to create an if statement in PHP that prevents a single post
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am confused How to use looping for Json response Array in another Array.
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.