whitespace COMPANY whitespace SERVICES whitespace PRODUCTS whitespace PURCHASE whitespace SUPPORT whitespace CONTACTS whitespace Home whitespace Contact Us whitespace Site Map whitespace
whitespace
SUPPORT
whitespace
FORUM
whitespace
FAQS
whitespace
SUBSCRIPTION
whitespace
REQUEST ON-LINE
whitespace
whitespace

Technical Support Forum

Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
View
Go to last post Go to first unread
Pat  
#1 Posted : Thursday, January 26, 2012 1:22:12 PM(UTC)
Pat
Rank: Newbie

Groups: Registered
Joined: 1/24/2012(UTC)
Posts: 2
Location: France

Hi,

I need to upload hundreds of images from the disk to a sharepoint List using Image Upload. I would like to create a powershell script to do this but I read the thread
http://www.artfulbits.com/support/forum.aspx?g=posts&t=275, and it appears that it is not possible. This thread was posted one year ago, so I wonder if there was an update to the product allowing us to do this?

Thanks for your support
stets  
#2 Posted : Thursday, January 26, 2012 6:09:45 PM(UTC)
stets
Rank: Developers Team

Groups: Registered
Joined: 5/27/2010(UTC)
Posts: 80
Location: Lviv

Hello Pat,

It is possible to upload pictures using SharePoint PowerShell to Image Upload column. The following code snipped demonstrates how to:

1) Initialize objects
Code:
$spWeb = Get-SPWeb -Identity http://SPServer 
$spList = $spWeb.GetList("/Lists/CustomList1")


2)Add UploadImages internal folder to this list (required, if it does not exist yet)
Code:
$spImageContainer = $spList.RootFolder.SubFolders.Add("UploadImages")
$spImageContainer.Update()


3) Each image should be placed in folder with unique name. So, we create this folder for image
Code:
$imgUniqueID = [System.Guid]::NewGuid()
$strImgFolderName = $imgUniqueID.toString("N")
$spImgFolder = $spImageContainer.SubFolders.Add( $strImgFolderName )
$spImgFolder.Update()


4) Upload picture to this folder
Code:
$file = Get-ChildItem C:\filefromdisk.jpg
$fileName = "test.jpg"
$img = $spImgFolder.Files.Add( $fileName, $file.OpenRead(), $false );


5) Add new item to SharePint list and set ImageUpload column value:
Code:
$spItem = $spList.AddItem()
$spItem["Title"] = "Test Item"
$imgUrl = $img.ServerRelativeUrl 
$imgDescription = "image description"
$spItem["ImageColumn1"] = ";#"+$imgUrl+";#"+$imgDescription+";#"
$spItem.Update()


Steps 3,4,5 should be done for every image.

Let me know if you have any question.

Beast Regards,
Yura Stetsuk,
SharePoint Support & Development Team

Edited by user Thursday, January 26, 2012 6:11:47 PM(UTC)  | Reason: Not specified

Pat  
#3 Posted : Friday, January 27, 2012 5:16:35 PM(UTC)
Pat
Rank: Newbie

Groups: Registered
Joined: 1/24/2012(UTC)
Posts: 2
Location: France

Hello stets,

Thank you for this quick and detailed reply. I let you know if I have trouble, as soon as I can test it.

Best Regards
Users browsing this topic
Guest
Similar Topics
Use Image Upload field in page layout (Publishing Components for SharePoint)
by iozag 9/19/2014 6:46:59 PM(UTC)
Use Image Upload field in page layout (SharePoint Products Support)
by iozag 9/19/2014 6:46:59 PM(UTC)
Image Upload: Cannot Upload image using code in a Custom Web Part (Publishing Components for SharePoint)
by Sree 10/5/2012 6:56:31 PM(UTC)
Image Upload: Cannot Upload image using code in a Custom Web Part (SharePoint Products Support)
by Sree 10/5/2012 6:56:31 PM(UTC)
Image Upload: Issue with Custom Permission (Edit only) (SharePoint Products Support)
by JoshSP 9/20/2012 2:23:59 PM(UTC)
Image Upload: Issue with Custom Permission (Edit only) (Publishing Components for SharePoint)
by JoshSP 9/20/2012 2:23:59 PM(UTC)
Image Uploader + Reporting Services 2005 (Publishing Components for SharePoint)
by ShareVision 7/26/2012 2:57:12 AM(UTC)
Image Uploader + Reporting Services 2005 (SharePoint Products Support)
by ShareVision 7/26/2012 2:57:12 AM(UTC)
Image Upload (SharePoint Products Support)
by Pat 1/26/2012 1:22:12 PM(UTC)
Image Upload JavaScript Object Model (SharePoint Products Support)
by sayitfast 7/30/2011 9:21:07 AM(UTC)
Image Upload JavaScript Object Model (Publishing Components for SharePoint)
by sayitfast 7/30/2011 9:21:07 AM(UTC)
Image Upload and Object Model (Publishing Components for SharePoint)
by gdelgiovine 5/26/2011 9:21:23 PM(UTC)
Image Upload and Object Model (SharePoint Products Support)
by gdelgiovine 5/26/2011 9:21:23 PM(UTC)
Image Upload column not visible for anonymous users (SharePoint Products Support)
by Natalie 5/11/2011 4:49:10 PM(UTC)
Image Upload column not visible for anonymous users (Publishing Components for SharePoint)
by Natalie 5/11/2011 4:49:10 PM(UTC)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Company | Services | Practices | Technologies | Career | Contacts | Privacy
© 2005-2017 ArtfulBits. All rights reserved.