Uploading and Storing Files in Database (1 Viewer)

Pac-Man

Active member
Local time
Today, 09:27
Joined
Apr 14, 2020
Messages
416
Hello,

I want to add option to upload a file in my database. I read many places that attachment is not so good option. Also I don't like adding as attachment because it'll increase database size because file size may be as large as 20mb. What could be better way to do that. I think of adding upload option through a form which store the file in a sub-folder of backend folder. Then linking that file to the record for which it was uploaded but problem is I don't know how to do it.

Best Regards
Abdullah
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 21:27
Joined
Oct 29, 2018
Messages
21,467
Hi. That sounds like a good plan. You will need a few components to do it.
  1. FileDialog object to let the user browse for the file they want to upload
  2. FileCopy statement to make a copy of the file into the subfolder you designate
  3. TableDef Connect property, if you don't know beforehand where the BE is located
  4. etc.
 

mike60smart

Registered User.
Local time
Today, 05:27
Joined
Aug 6, 2017
Messages
1,904
You can have a Form that displays the Path to the file(s) which are stored either on your Local Drive or the Server

See the attached example
 

Attachments

  • HowToHandleAttachments_Demo.zip
    58.4 KB · Views: 413

Isaac

Lifelong Learner
Local time
Yesterday, 21:27
Joined
Mar 14, 2017
Messages
8,777
Adding one more thing to dbGuy's suggestion. This is more for "down the road"--at the time when you're thinking of how to design a way for the user to retrieve/view/open the file. Once you're at this point, I recommend copying the 'real' file to a local machine location, and then allowing them to open the copy of the file (rather than the real file)--Unless, of course, you actually DO want to let the user edit or impact the real file.
 

Pac-Man

Active member
Local time
Today, 09:27
Joined
Apr 14, 2020
Messages
416
Hi. That sounds like a good plan. You will need a few components to do it.
  1. FileDialog object to let the user browse for the file they want to upload
  2. FileCopy statement to make a copy of the file into the subfolder you designate
  3. TableDef Connect property, if you don't know beforehand where the BE is located
  4. etc.
Thanks a lot for explaining the steps required. Right now, I don't know how to apply them but will google for getting the steps done.
You can have a Form that displays the Path to the file(s) which are stored either on your Local Drive or the Server

See the attached example
Thanks for sharing sample db. It'll definitely save me a lot of time for applying the steps as laid down by @theDBguy.
Adding one more thing to dbGuy's suggestion. This is more for "down the road"--at the time when you're thinking of how to design a way for the user to retrieve/view/open the file. Once you're at this point, I recommend copying the 'real' file to a local machine location, and then allowing them to open the copy of the file (rather than the real file)--Unless, of course, you actually DO want to let the user edit or impact the real file.
Thanks for suggestion. I would prefer my user to download the file and then open.

I will try to implement this feature in my db and any more demo db is highly appreciated.

Thanks a lot everyone again.
 

Pac-Man

Active member
Local time
Today, 09:27
Joined
Apr 14, 2020
Messages
416
You can have a Form that displays the Path to the file(s) which are stored either on your Local Drive or the Server

See the attached example
Dear @mike60smart, I checked the db. It is very helpful. I will use the method 2 described in it for my requirement. This solve my issue for uploading. I'll still need help for downloading. I want users to get dialogue object option for saving/downloading file when someone click to download or open the file so that they can save the file on required folder on their hard drive.
 

Users who are viewing this thread

Top Bottom