How to determine who uploaded file [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I have a system that allows users to upload .doc files..I'm using PHP and renaming these files the memberid.doc so that I can determine which user uploaded that file and give him the option to delete that file. I would like to keep the file name the same though. Is there any way I can do this and still track which user uploaded that file?

You could keep a MySQL database of filenames and by which user they were uploaded.

I think you will store the files in the same folder, and worrying if a file of the same name is uploaded it would delete the older file, to prevent it from happening u have to give a new name to the file that is stored in server (something related to the user id)
the table would be
user_id filename serverFileName
filename would be name of file the user uploaded, like android.jpg
serverFilename would be the name file as stored in server like user4_1.jpg

Related

How to get image data from database mysql in react native [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a problem, I am using backend with Codeigniter and upload the image to MySQL with varchar type.
This is the name of the image after I input:
and now I want to get that image to react native with fetch API, but how to get image from database to react native, because in MySQL just the name of the picture is saved? please help me
You have to save the file on the server's disk and filename name in your database. You'll have to know the location of your file so when you want to fetch it you'll have to build a full url to the file like http://example-domain.com/uploads/filename.jpg or you can save the full path in the database instead of just a filename. If you don't have a server to store the image you may consider saving the image blob into the database which I don't recommend.

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).

Storing a file into a database & uploading it in a webpage [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
Background
I'm creating a website where the user can store an article as a file in the database and than upload the file's content into a page in the website using a form. The file may only contain text or image or both.
Question
Can anyone walk me through this?
I would suggest you to create a database table having fields having the userId, and path of the file.
The file uploaded should be saved in the Web Server, and its path need to be saved in the database.
The vice-versa should be done while retrieving the file content.

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.

Read the file when files is added to a folder and insert the content to a database [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to listen in on the folder (see if there are any changes) and when any file is added I want to insert the content of that file to a table and delete the file afterwards.
create a db table to keep track of files in the folder
create a script that compares folder contents with that db table
if files found which aren't in the table, sanitize content and insert into db, and add filename to tracking table
if a file in table is no longer in folder, remove that file's content from db and remove from tracking table
set script to run via cron so that it checks folder at the interval you specify
hope this helps point you in the right direction :)

Categories