Save images from Access database to dropbox folder - image

I have a MS Access 2010 application with an item table that stores the image of the item. How can I save this image in a Dropbox folder?
Exemple
Table: ItemTable
Fields: ID = 0001, DESCRIPTION = Item1, CATEGORY = C1, CUSTOMER = Cust1,
FOLDER = CATEGORY & "\" & CUSTOMER, IMAGE = Item1.jpg
I need to save the image Item1.jpg in a folder C1, subfolder Cust1, into dropbox. The data type for the IMAGE field could be a string data (the image file is located in a folder on the hard drive of the local pc) or could be a OLE object, doesn't matter.

You can use FileCopy in VBA, for example:
FileCopy "C:\Images\Img1.jpg", "Z:\Users\Raul\Dropbox\Public\SavedImg1.jpg"

Related

Display a different image on combo box change in Access without file paths

I am creating a form that contains a combo box, lets say it's called 'Postcode_cb'. I want to have a unique image displayed for each of the items in that combo box. The images have to be in the same position and replace each other when the combo box is changed so that there is only ever 1 image. This has to be done without the use of file paths.
For example:
Try this way: create table [tblImg]([id], [picture]) where [id] is long and [picture] is OLE.
Insert two records with id=1 and id=2, embed corresponding images into [picture] field.
Then create stanalone form [frmImages] with rowsource [tblImg] and put 'bound object frame' with control source [picture].
Put [frmImages] as sub form at your main form.
Set LinkMasterFields to [Postcode_cb] and LinkChildFields to [id].
I have something like this on a database that gives out star rating of hotels. As you browse through the hotels it displays actual stars depending on the rating. The way that i did this was placed all the images in 1 spot (Placing them on top of one another) Give each image a name. and set them all to visible = no.
Example Img1, Img2 etc. until all images have a name.
Then open Visual basic and create a sub called Private Sub Form_Current() if you don't already have one. Then under this sub use the following Code
Forms![FormName]![ComboBoxName].SetFocus
Select Case Forms![FormName]![ComboBoxName].Text
Case Is = ""
Forms![FormName]!img1.Visible = False
Forms![FormName]!img2.Visible = False
Case Is = "1"
Forms![FormName]!img1.Visible = True
Case Is = "2"
Forms![FormName]!img2.Visible = True
End Select
This is only good if you only have something like 5 to 10 images anything more would be a lot harder to deal with in this way.
There maybe other ways people can suggest i found this the most easiest for my needs.

How to upload image on server's image folder

This is my spring project structure.
I have to upload hotels picture in image folder. But i am not getting path of image folder.I tried below code
//There is some code here
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List items = null;
items = upload.parseRequest(request);
Iterator itr = items.iterator();
while (itr.hasNext())
{
FileItem item = (FileItem) itr.next();
itemName = item.getName();
File savedFile = new File(request.getRealPath("/")+"image-folder\\"+itemName);
item.write(savedFile);
}
but it is giving error : Directory not exist.
Now I have two question.
What is solution of above problem?
Is this a right way to upload image in server's image folder? Because it could be temporary i have read on stackoverflow?
Edited:
Runing project from eclipse and when i printed path it gives
E:\DeepakWork\current\jmx_examples.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\HotelManagment\image(file-name)
I first want to answer the second most important question
Is this a right way to upload image in server's image folder?
No, it is not. Because it is a security issue! Never ever upload any user generated content in the web application folder!
Instead upload the files in some fixed (configured) folder somewhere outside of the Tomcat Directory.

External Images Referencing in ACCDB

I have a database application making use of VBA code that has reached its 2GB size limitation with image attachments on a per-record basis. We're wanting to have all forms in the application move away from "uploading" images as attachments for records, and instead upload them to a directory on a network server and reference the image files in the forms.
At this point, I'm trying to figure out the best way to approach this. Is it feasible to have the user somehow pull up an "Upload" dialog through an Access form? I've tried a couple cobbled-together solutions for Open File dialogs in VBA, but they've never quite worked properly.
Summary: File type is ".ACCDB", I need to allow users to upload images in a New Record creation form, have the images stored in a Network directory, and accessed on-the-fly throughout the application.
Thanks in advance.
From a general database point of view, you should not store images directly in a database, unless they are very small (less than 1 MB approximately), and you actually have the space to store them. The most common practice is to store the image path in the database, and then load those images directly from your the file directory where the images are stored when needed. It will add another level of complexity, but will reduce your DBs size radically.
Update:
This code allows the user to click some element frame in the form, store the path in the DB (with path as the username.jpg), and display the picture to the user afterwards in the clicked frame:
Private Sub SignatureFrame_Click()
On Error GoTo ErrorHandler
' Get path for the new picture from a dialog box
Dim Path As String
Dim fd As FileDialog
Dim ffs As FileDialogFilters
Set fd = Application.FileDialog(msoFileDialogOpen)
With fd
Set ffs = .Filters
With ffs
.Clear
.Add "Pictures", "*.jpg"
End With
.AllowMultiSelect = False
If .Show = False Then Exit Sub
Path = .SelectedItems(1)
End With
' Update the picture in the user interface
Me![SignatureFrame_Click].Picture = Path
' Copy the signature into the local Signature folder of the DB
Dim fs As Object
Dim oldPath As String, newPath As String, file As String
oldPath = Path 'Full path the file is located in
newPath = CurrentProject.Path & "\Signatures\Users\" & Screen.ActiveForm.UserName & ".jpg" 'Folder and path to copy file to
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile oldPath, newPath 'This file was an .jpg file
Set fs = Nothing
' Set the new picture path for the form
Screen.ActiveForm.SignaturePath = newPath
Exit Sub
ErrorHandler:
MsgBox "Could not upload the image. Please check that the file format is of type jpg."
Resume Next
End Sub
Then at some later point in some other form you can retrieve the image like this:
Me!SignatureFrame.Picture = CurrentProject.Path & "\Signatures\username.jpg"
PS: The code has been translated in the SO editor, so I cannot guarantee that there are no mistakes.
Hope that helps!

How to save and view image in window phone 8

I a working on a simple window phone application. In which I have two filed Name and Images.
I want to save this item and want to view all saved data.
Now My query How to select images to save? and How to save images and also get images to view.
I also used PhotoChooserTask but How to save selected image and how to get saved images?
I know about how to save image file in Isolated storage. But how to save selected images and get all data?
Thanks,
Hitesh.
Thanks for your reply. I knew about photoChooserTask. I also save my image file in isolated storage. But I dont know what is the images path to save images path in database and how to display all those images in datagrid. I have a table which have fields like ID, Name and Image path. I dont know what to save in imagepath filed if I saved image in isolated storage and how to display all data in datagrid.I used following code to save data into database. IN below code please correct the image path if I was wrong.
CategoryVO newCategory = new CategoryVO()
{
Name = txtCategoryName.Text,
ImagePath = txtCategoryName.Text.Trim() + ".jpg"
};
Expdb.Category.InsertOnSubmit(newCategory);
Expdb.SubmitChanges();
Using the PhotoChooserTask you can actually launch the photo chooser application and handle the selected image.
If you want to integrate this in your application, create the instance of the PhotoChooserTask and call the Show() method. If you want to handle the user’s selection, register the Completed event which will give you handle of the chosen photo.
var photoChooserTask = new PhotoChooserTask();
photoChooserTask.Completed += PhotoChooserTaskCompleted;
photoChooserTask.Show();
In the completed event implementation, you can get the chosen image as PhotoResult and set the image to your Image control or can use it in other places.
void PhotoChooserTaskCompleted(object sender, PhotoResult e)
{
switch (e.TaskResult)
{
case TaskResult.OK:
imageChooser.Source = new BitmapImage(new Uri(e.OriginalFileName));
break;
}
}
Source: http://www.codeproject.com/Articles/350126/How-to-use-the-PhotoChooserTask-to-Launch-the-Medi

How To Upload a File in MVC3?

HI all i have a situation like this ......
AttachmentName:[TextBox] [FileuploadControl] Add
[Upload]Buton
when the user Gives the FileName and Uploads the file name and clicks on add i want to display the Attachment Name in a GridColumn and when he is finished and clicks on Upload button i want to save the file in this path
string savefilename = Path.Combine(Server.MapPath("~/Upload"),
Path.GetFileName());
and i want the uploaded file name to be Attachmentname entered in the textbox...and i wan the url of uploaded file to be saved in database...can any one give me any idea how to do this

Resources