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 Search | Active Topics | Log In | Register

Image Upload Options · View
Pat
#1 Posted : Thursday, January 26, 2012 11:22:12 AM
Rank: Newbie

Groups: Registered

Joined: 1/24/2012
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 4:09:45 PM
Rank: Developers Team

Groups: Registered

Joined: 5/27/2010
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
Pat
#3 Posted : Friday, January 27, 2012 3:16:35 PM
Rank: Newbie

Groups: Registered

Joined: 1/24/2012
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
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-2016 ArtfulBits. All rights reserved.