Uploading different file on different column of database table - php

I have employee form that I use to store employee full information including cv, contract papers, and other documents.
How can I upload these different files for one employee using php And mysqli?
Here what the table should look like:
Id name email resume(file) contract(file) edu_docs

I would highly discourge you from saving files in a database like that.
Here are the steps that I have used before:
I would create a folder on the server for each user.
Save the filename and extension in a table.
Save the file to the server.
If I wanted to grab a file I would go to the right directory and file name.
Examples:
Resume = {userFiles/userID/filename}
Contract for Billy = {userFiles/{Billy'sID}/{filename}

Related

Add image to existing MySql record

I'm quite new to PHP and MYSQL.
I need to add an image to an existing record.
So I have a list of records and when I click the link directing to this page.
In this form I would like to ad an image.
Thanks in advance
I would highly discourge you from saving files in a database like that.
Here are the steps that I have used before:
I would create a folder on the server for each user.
Save the filename and extension in a table.
Save the file to the server folder.
If I wanted to grab a file I would go to the right directory and file name.
Examples:
Profile Picture = {userFiles/userID/filename}
Contract for Billy = {userFiles/{Billy'sID}/{filename}

grocery crud file upload field pick file from server

I'm developing a web site with codeigniter + grocery crud.
I really like the upload file feature from grocery crud.
But I'm wondering if it's possible to pick a file from a server folder instead of uploading it. I mean just put the name of the file in the field.
I don't want to write more than what is needed.
Edit: I want the user to be able to do both: upload a file, or pick it from a server folder.
I've been asking myself the same question. I was thinking in doing it like this:
1 - Create a Media Library table (Wordpress style) and store all the file uploads in a table.
2 - Add a relation field to select images form this table.
http://www.grocerycrud.com/examples/set_a_relation
The basic relation field will generate a select that allows you to select images by name, id, description, etc.
This is not very user friendly, so I guess you'll have to write one or two callback functions to show the users the image they are selecting
this is the approach I'll be using on my next codeigniter+grocerycrud project :)
Good luck!

Codeigniter - Download a upload file in the directory

I'm using the latest Codeigniter version, and I write a program about basic file uploading and download helper in http://ellislab.com/codeigniter%20/user-guide/helpers/download_helper.html.
I want to create a system that will upload a multiple files to the directory and save the file name to the database and the name of the uploader, and will have function to have download links to download every file of that specific user. If possible the system can email the encrypted link to the users to download the file. And can only download for specific time..
I don't know the logic in dynamic files to download. Can someone teach how to do this or what logic can solve this problem. Thank you very much! :)
For multiple files you have some alternatives, you can create each field as a user press a button or use the multiple propriety to <input> tag.
To manage this multiple uploads you must create your own upload library reading each $_FILES['nameoffield'] in a foreach loop for example although there are alternatives ready to be used like: https://github.com/nicdev/CodeIgniter-Multiple-File-Upload
On your database, you could have two fields that stores the original file name and path, and the encrypted one. Probably associated to a random unique number or timestamp.
To email encrypted link, and by encrypted I think you are saying a disguised link to the file, not using original name, you simple select the field which store the encrypted name to a controller, like download and keep a variable to receive a value as parameter. This value you must check on database if it really exists and then redirect to the file. By doing that you should have your file being downloaded.

How to add PDF files in a database and be able to search for them through a website using phpMyAdmin

I am working on a website and the owner wants to use PDF files to show the contents of a bill for users to see what they owe. He wants to be able to search through the website using specific search criteria. For example, the PDF number, a certain town, a certain year etc... I have a form already made to use to search for these PDF files, I just don't know how to store the PDF files in the database using phpMyAdmin. Can anyone help?
I think you should keep all the metadata and filename in the database and store the actual files in uploads/ directory. When you search for a file by its ID, city or whatever, you'll retrieve the filename and you'll be able to redirect to a particular file.
Personally I'd change all filenames to uniqid().'.pdf' so that they don't repeat and have constant length.

Match up database record with image from upload folder

I have a database with users information such as name, email etc in. When they sign up they must upload a picture. At present when they do. the image goes into a 'uploads' folder on the server.
My question is, how do i go about aligning up the database record with the corosponding image in the folder?
You should store the file name / url (make it unique, md5 the users ID or something) in the DB as a reference, this is the best way to handle this type of photo + user relationship.
And as normal, just save the actual file in /uploads/
Simply create a column in your DB called user_photo and save the link to the file /uploads/john_smith_321sf.jpg
That way in the future, you just retrieve it using your database data.
You can name the image with something that is unique in the database. For example if 'John ' whose user id is 157 uploads an image, name the image 157.jpg - you can then query the folder for that id and extension.
Sorry, re-read the comments.
I'm assuming then that your upload file is out of the document route, is that correct? Will this help:
header('Content-Type: image/x-png'); //or jpg....
readfile('displayfile.png');
die();

Categories