• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 929
  • Last Modified:

Saving image from clipboard to a file

Hi

I need to save an Image from the clipboard to the database.
First, I want a user to get the image, by pressing GET IMAGE button, from the clipboard and display it on the page (100X100 pixels, just for user to see that he got one).
Second, by pressing a SUBMIT button, the image will be saved on the server by the name (“nnn”) in the provided path and the image name (“nnn”) will be saved in the Access database record.

I am using VS2010, VB and very novice to ASP and veb design.

Thank you in advance,
Dave
0
Yucel Altingoz
Asked:
Yucel Altingoz
  • 8
  • 5
1 Solution
 
radcaesarCommented:
Assume that its an web application,

1. When the user click on the button, Open that image on the browser using "window.open" of javascript

2. When Pressing pressing the submit button, strem the same image and save it to access db to a lob.

The main question now is, where the 2nd submit button resides?

If it is in the target page then my above logic will change slightly.

Your clipboard logic will be taken care by OS internally, Actually its not CLIPBOARD.
0
 
Yucel AltingozAuthor Commented:
Hi radcaesar

Thank you very much for the replay, but can you please explain a bit more?
I have never worked with javascript and don't know how to implement "window.open" of javascript putting an image from the clipboard.

Thanks,
Dave
0
 
CodeCruiserCommented:
Is the image in client computer's clipboard?

If yes, its not so straight forward as webpages can not access client clipboard. You would have to write an ActiveX control or a Java Applet. Check this

http://www.eggheadcafe.com/articles/20010713.asp
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
Yucel AltingozAuthor Commented:
Hi
Thank you very much for yours replies.
Searching through the web I found the following code. It was written in C# and I converted it VB.(Unfortunately I don't remember where I found it). It seems to be working fine.
Can anybody tell me if this is the right way of saving image from Clipboard in ASP.NET?
-------------------
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Threading

   Protected Sub Button1_Click1(sender As Object, e As EventArgs) Handles Button1.Click
        Dim cbThread As New Thread(New ThreadStart(AddressOf CopyToClipboard))

        cbThread.SetApartmentState(ApartmentState.STA)
        cbThread.Start()
        cbThread.Join()

    End Sub

    Protected Sub CopyToClipboard()
        Dim dObj As IDataObject = Clipboard.GetDataObject()

        If dObj IsNot Nothing Then
            If dObj.GetDataPresent(DataFormats.Bitmap) Then
                Dim resimMap As Bitmap
                resimMap = TryCast(dObj.GetData(DataFormats.Bitmap), Bitmap)
                resimMap.Save(Server.MapPath("resim.jpg"))
            End If
        End If

    End Sub

Thanks,
Dave
0
 
CodeCruiserCommented:
The code is saving image from SERVER clipboard and you still have not confirmed if that's what you want.
0
 
Yucel AltingozAuthor Commented:
Hi CodeCruiser

I apologize for not answering to you erlier.
I need to save an image from client computer.

Thanks,
Dave
0
 
Yucel AltingozAuthor Commented:
A clipboard image from client computer.
0
 
Yucel AltingozAuthor Commented:

Hi CodeCruiser

Can you please tell me how can I ran the code from http://www.eggheadcafe.com/articles/20010713.asp?
I downloaded the project but don't know how to open it.
(I have never written a cide for ActiveX or Java Applet.

Thanks,
Dave
0
 
CodeCruiserCommented:
0
 
Yucel AltingozAuthor Commented:
Hi CodeCruiser

I tried to follow the explanation but got a bit confused (as I mantiod eralier, I am totlaly new to asp.net and web desight, let alone ActiveX)
I thing ithe example starts as C# project ("Once the project is created, delete the Class1.cs ") but then it says ("private Dim mStr_UserText as String") "Dim" to me is a VB defenition.
So it got me nowhere.

Can you please clarify this for me?

Thanks again for your help,
Dave
0
 
CodeCruiserCommented:
The auther may have got it mixed up.
0
 
Yucel AltingozAuthor Commented:
Hi CodeCruiser

Thank you for your help, but
the example has errors that I don't now how to fix them since I am in the learning process myself.
Is there an example with working javascript code doing similar to what I need?

Thanks,
Dave
0
 
CodeCruiserCommented:
I have not done it myself and I could not find many examples on the net either.

Can the user not upload a file instead?
0
 
Yucel AltingozAuthor Commented:
Hi

It is possible for the users to save an image from clipboard with Paint app and then upload to the server.
We just want to eliminate the step in the middle of opening Paint, saving and then uploading (our users are not very much computer oriented).

Thanks,
Dave
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now