Skip to main content

Download Data File From SharePoint

How to download Files From SharePoint Using php?

This example is useful to download sharepoint data file using php. I have try to download sharepoint file using PHP CURL and i have done it so try it.

<?php
$sp_login_id = "test"; // sharepoint user id
$sp_password = "********"; //sharepoint password
$sp_data_file_url = "http://server/test.doc"; // data file url


$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$sp_data_file_url); // set url to post to
curl_setopt($ch, CURLOPT_USERPWD,"$sp_login_id:$sp_password");
curl_setopt($ch, CURLOPT_FAILONERROR, 1); // curl error
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 5000); // times out after 5s
curl_setopt($ch, CURLOPT_GET, 1); // set GET method
$result = curl_exec($ch); // execute the whole process

//curl errors
$curl_info = curl_getinfo($ch);
switch($curl_info["http_code"]){
case 401:
die("Incorect userid or password.");
break;

case 404:
die("Incorect data file URL.");
break;
}

$fo@fopen(basename($sp_data_file_url),"w");
@fwrite($fo,$result);
@fclose($fo);
?>

Comments

Popular posts from this blog

Flex Interview Questions

1) What is Flex? Flex is used to devleop Rich Internet Application (RIA) You can both desktop & web based applicaiton.It is markup language and object-oriented languages its many syntax match with flash action script. Flex Developers use typically five distinct phases to develoep Rich Internet Application. Design Configure Build Deploy Secure 2) How do i get Page URL and Query String ? We can use mx.core.Application.application.url (mx.core)package to work with current page URL. & query string. 3) Describe flex component file types ? There are following file types we can use in flex. extension .mxml - a component implemented as an MXML file. extension .as - a component implemented as an ActionScript class. extension .swc - a SWC file contains components in a packge. 4) Difference between target & currentTarget ? target : This property is set by the dispatchEvent() method. You cannot change this to a different object. currentTarget : This property is set by component instan...

Free Online Meta Tag Creator

Meta Tags are HTML header part tags, which describe about the website . These meta tags provide information to the search engines such as Google, Yahoo, MSN Search, AOL Search, AltaVista ,HotBot, Lycos, Excite and other search engines . It is very important to the search engine point of view meta tags must be well formed and meaningful . HTML Meta tags help to increase your website rank. The common questions arise for meta tags are as follows? What Are META Tags? META Tags are HTML header part tags of HTML Document that provide internal & external information about the content of a web page or website while you are browsing that page you are not able to see that Meta tags on your browser output. How META Tags Work for Search Engine? Meta tag tell to search about the page such as keywords, Description, Content Language etc, which parameter you put in contents attribute of the meta tags that's is read by search engine to index your page with accuracy, which is totally depend to...