Uploading multiple image how to store them [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 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.

Related

How to validate array of files in Laravel? [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 7 months ago.
Improve this question
I'm working on a project where every user is able to add multiple product images. I'm using a single form to submit the product which does 2 things in ProductController#store which are creating new product + creating images belongs to this product in Images table.
The important part is that I want to allow users to upload total of 10mb of images per product. So mainly I want to validate total files size of the array of images the user trying to update.
I found this solution: Laravel Validate Array of Files Total Allowable Upload Size
This solution is almost 5 years old so I was wondering if there is an easier way, or a more straight forward way to accomplish this?
I have mixed the stackoverflow solution with Laravel's custom validation rule which solved my problem with a modern solution.
https://dev.to/moose_said/create-custom-laravel-validation-rule-for-total-uploaded-files-size-1odb

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 a file that you have uploaded into the database [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 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).

I need to create a database structure that will do the following [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 want to be able to upload multiple images (i got this working) its array
only problem is i need each image to have its own content but i want to use one form as this relates to a specific article.As you see this picture
This welcome article for example has a heading, an image and text to explain for each image .
this is my current db structure but as you can see there is no way content will be separate for each image
article id is the foreign key
How could i achieve this in a database structure?
You talking about uploading images to your server right ? if so:
You got few options to do it:
Create a 'unique' id and put them inside the image element and the content element.
Then you will get two arrays and you combine them by the unique.
Almost the same, just simply to store the content and the images inside arrays. and just loop through them and 'combine' them by the array's id. because you inserting the same amount so it should be the same. But answer 1 is safer here.

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.

Categories