I have a form, and that form has a field for a Picture and a Thumbnail which are currently Single Text fields. What I would like to do is when people input a URL on those fields, I would like to get the image of that URL and save it onto a SharePoint Picture Library.
I can find the value of the fields by using jquery, but I am wondering how can I find them on the back end.
According to this site: http://social.technet.microsoft.com/Forums/sharepoint/en-US/50deca94-71b4-4081-9dc6-81fc7e86886f/how-to-read-image-file-from-a-url-and-save-the-image-in-image-library-in-sharepoint-2010
It looks like I need this to get the image in the SharePoint Library
using (SPSite oSiteCollection = new SPSite("http://localhost"))
{
SPFolder oFolder = oSiteCollection.AllWebs["TargetWebSite"].GetFolder("TargetDocumentLibrary");
SPFileCollection spFileCollection = oFolder.Files;
string targetFileUrl = spFileCollection.Folder.Url + "/" + "cust.png";
spFileCollection.Add(targetFileUrl,imageBytes, true);
}
My issue is how do I get the url, is it okay if I just use jquery, or how do I tell this I have the url so it can save it to the appropriate folder.
So I was able to download an image using this code:
string localFilename = @"c:\tofile.jpg";
using (WebClient client = new WebClient())
{
client.DownloadFile("http://img.talkandroid.com/uploads/2013/03/wpid-photo-jan-14-2013-1115-am.jpg", localFilename);
}
but how would I go about it and
Save it to a sharepoint picture library, something like this: SPList mylist=objWeb.Lists["Shared"];.
I will need to use ajax to pass my parameter? such as instead of a hardcode url, a url that somebody inputs in a field.
Thanks.
Event Receiver
instead of jquery?