What type of data will I use if I want to save a file with a user using PHP and MySQL?

I want users to be able to upload their resume in PDF, .txt, .doc, .docx; and let potential employers upload the file.

What type of data should I use? In MS MSQL, I would use varbinary (max), right? But since I'm new to MySQL, I'm a little confused. :)

+3
source share
7 answers

You must use blob type

+10
source

You must use varchar holding the file path. The file itself should not be stored in the database.

+4
source

, db flickr.:)

, , - , . ( ) , , . , db "" . , , .

, . .

+3

, DOC MySQL. MySQL BLOB varchar.

0

I agree with most of them above. As a rule, it is not recommended to store files in a database, unlike Facebook, which stores thumbnails in a database.

0
source

At this stage, both options above have their pros and cons. questions

  • the file size increases when saved as a blob and
  • does performance affect

regarding storage and loading from the server.

0
source

filename.php using the form submission method in this file

Upload File<a href="download.php?f=<?php echo $upload_file ?>"><?php echo $upload_file ?></a>&nbsp;<input type="file" name="uploaded_file" id="uploaded_file" value="">

Get published file in php

$file = $_FILES['uploaded_file'];    //receive the posted file
    $name = $file['name'];
    $path = "C:/wamp/www/mantis/uploads/" . basename($name); // 5
    if (move_uploaded_file($file['tmp_name'], $path)) {

    } else {

    }
**mysql query**
insert into tablename(upload_file)values('".$name."');
0
source

Source: https://habr.com/ru/post/1734576/


All Articles