uploading a file that you have uploaded into the database [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
is there a way to upload a file that the user have uploaded before into the database? eg, you have uploaded a resume into your own profile page (online) and now, you would like to send this same resume (online) to another person by uploading to the same website. however, it has to be chosen from your profile page

It is possible, but pointless. As #Mubin Khalid said, you should store these resources as files and store their path in the database. The file can be accessed through its path and you need to load only that from the database. If you want to duplicate files, then you have serious problems with the design of your database.
You need to have a table for resources, like this: resources(id, path). Naturally, based on your business logic, you might need other columns, like resource_type or owner. To handle attachments, you need to tackle with the n:m relation types using intermediate tables, which will have a foreign key which references resources(id).

Related

Should a PHP cloud storage application create a new table for each user with rows for each user files? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Should a basic PHP cloud storage application create a new table for each user with rows for each user files?
Currently, (after log in) the application gives each user their own directory and the php loops through each file in the directory and outputs it on their dashboard. The user can then download and view their data. Should i be using a database system for user's files?
What would the benefits be of using a database for this type of application?
You should definitely add some sort of abstraction layer in the form of a database for many reasons one of which being performance. When a users directory starts holding many files it will become memory expensive to read the file-system directly each time. Abstracting the contents of a directory into rows within a database table will give you speed, scalability, and a way to later on index and search your files as well as being able to title or tag files etc.
The design of your database schema can vary from application to application one might do as you said where each user gets their own table but that would be far more complex than lets say having a single table with a column specifying the owner of each file (by user ID).

PHP Media storage , media input in page [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
How could I store my media files (pictures, videos etc)? I am building a simple web app like a social website ,using php. I don't really know how could I save my pictures in a datbase for the moment when I log in with a certain user, i can see all his data (pictures, etc). And how could I link more pictures, for example if I have a "add image" button in the middle of page, i want to upload as more photos as i want, and for every photo using a storage method.
You'll want to store the image names in a database.
For example -
You could create a table in the database called "posts" or "images" and store the image file name in the table and associate it to the user who uploaded it.
Example table structure could be: id, user_id, image_name
You will then write a query to get the images by the users ID stored in that table.
It's fairly simple and I've done it many times.
I hope this helps.

Uploading multiple image how to store them [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Okay so I am doing this project and i need to allow the user the ability to upload 6 images, how should i go by doing this on the database side of things.
Make a column for each image
Store it in one column as an array and then do the processing of the array with PHP?
I will be useing the Yii Framework and also MySQL as a database engine.
I know how to upload file and store it to a directory and the other needed things, just not sure what to tackle the problem.
EDIT: My final goal is to have this index page edited by one user (Admin) and I want him to allow him to edit the images and the current offers as well.
You should create table user_images beacause:
You can change number of images pef user in the future without changing database
You can easily display all images in GridView and easly generate CRUD for user images.
You can easily store versioned list of images for user.
Implementation and code reusable will be simplier.
You should create a new table called "user_images(id, user_id, image_url)" to store image.

Upload and Retrieve a file with PHP [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I've created a small website with PHP and MySQL. The website allows a user to fill in a questionnaire (which is saved in a database) and then an admin person needs to view and then upload results in PDF format so the original person can view them. In fact the admin person can upload multiple PDF's (over time not in one sitting) to give more feed back which need to be accessible to the user.
My question is, what would be the best way to do this? First, should I upload files via PHP or would jQuery or the like be better? Should each person get their own directory? (does it matter if there are 100's of users?) How can I read all the files that pertain to a particular person and then allow them to view/download it?
Thanks in advance!
you can use form and php to upload file. If you need validation do it with php (for server side validation) or javascript (for client side validation), i recommend that you do both.
To distingusih between user data, you can use prefix for filename with username or something (ie. user1_file1, user1_file2, user19_file18), since i think it will be messy to create folder for each user.
To give link for user to download just add "location" column to your user database that contain the file path in your server. With this, you can check their username and every file that they upload in your database.

The storage construction of user avatar [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
User avatar is an important part of every website. How should I store the avatar image files on the server with high performance?
Here are some points have to solve:
How to generate the file name of user? Directly by user id or name,
or by the hashed/md5 id/name?
How to storage the file? All in one dictionary or in different dictionary (How to?).
The avatar file can cacheable if the link of the file is permalink, but what if the user change the new avatar?
Personally, I store a text field in the user's database row, of the format:
WWW|HHH|URL
The width and height (WWW and HHH) are fetched when the user selects the file, and the URL is simply the address where the avatar can be found.
You actually save a huge amount of bandwidth by not putting user's avatars on your servers.

Categories