How to execute custom sql query in elfinder file manager - php

I am using elfinder file manager in one of my project. I am developing my project in PHP. I am new with using this file manager.
Now, I want to execute an SQL query when file will be uploaded and want to put track of each file uploaded with each user separately. So I am not getting that how to customize this thing.
For Example, I am a user and I have registered. Each user has their separate account and they can upload their files there in his/her account.
Now, suppose I am user and uploading 1 image in my account. So when I am uploading my file. I want to insert that file name, size and all other details with user_id in my database table. So I can manage track of each user uploaded files.
Please any one can help me here for this?
Thanks in ADVANCE

If i am not wrong you want to know how to store uploaded files data in database then You must read php manual about file upload feature
on other hand you just need to explore $_FILES array as it contains all details of Uploaded file

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}

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.

Access folder and select filename using PHP

I have written a code, where the user selects a profile picture and then the picture is stored in localhost/user/$username/photos/photo1.gif.
After that, I assigned the filename (photo1.gif) into a session variable so I can display it from all my php scripts. This is working just fine. I can display the picture in every php script by accessing this session variable.
The only problem I have is when I am trying to login from the login page: In the login page I connect to the database, retrieve email and password, check them and if they are OK I redirect the user to home.php. The problem is that the user's photo is not linked to the email so i cannot know the filename of the photo. The only thing I know for sure is the directory (because I can retrieve username from database as well).
Lets say that a user has uploaded 4 photos (photo1, photo2, photo3, photo4 - photo4 was uploaded last). It makes sense that he is currently using photo4 as my profile picture.
Is there a way for me to access that folder and retrieve the filename of the picture uploaded last?
Also, as a general question, what is better, store the photos(or files) in a database or server?
A few options:
It would be 'better' to create a photo table and store the user_id and the photo location in that table. Storing the actual photo in the table as a blob is not generally recommended.
Alternatively, to avoid more tables, you could rename the photos as
username_photo1.jpg
username_photo2.jpg
username_photo3.jpg
And then you can retrieve the largest of them.
Finally, another option is to get the file creation date of the photos in the directory and take the most recent photo.
see Getting the filenames of all files in a folder

customize elfinder file manager

I am using elfinder file manager in one of my project. I am developing my project in PHP. I am new with using this file manager.
Now, I want to execute an SQL query when file will be uploaded and want to put track of each file uploaded with each user separately. So I am not getting that how to customize this thing.
For Example, I am a user and I have registered. Each user has their separate account and they can upload their files there in his/her account.
Now, suppose I am user and uploading 1 image in my account. So when I am uploading my file. I want to insert that file name, size and all other details with user_id in my database table. So I can manage track of each user uploaded files.
Please any one can help me here for this?
Thanks in ADVANCE
You can use custom callbacks. For example, after uploading make ajax request, which save file parameters to db.

How to create user-accounts' separate folders to save user data in--PHP

How would I save each user's 'default photo' onto a website? This same photo may be used during some of their interactions on the site(maybe in a chat session), and it may be displayed on their profile page. Will each user have their own folder? If so, how can I create such a folder. Will this folder stay on ftp? Or MySQL? Will it take any space? As of now, whatever photos are uploaded onto the server, are simply stored in a folder that reads--'uploadportrait.php'. Where can I go from this? If someone can tell me the general principles of this, then that would be great! Thank you in advance.
If it is just one photo it doesn't make much sense to create a folder for each user. If you already have a working upload routine, simply store the file path of the uploaded file inside of the user database. You don't need to duplicate the image then.

Categories