Monday, October 27, 2008

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.

$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);
case 401:
die("Incorect userid or password.");

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


Wednesday, October 22, 2008

JavaScript Cookies Functions

Java Script Cookies Set and Get functions

There are four function which is useful to work with javascript cookies. there are no predefine function in javascript so that we can use these function to work with browser cookies. here is description of functions.

1) Javascript function set_cookie(name,value) :- This is a void function take two parametters name & value. name param is used for cookies name & value is used to set cookies value.

2) Javascript function get_cookie(name) :- This string function, which return value of that particualr cookie which you pass as param.

3) Javascript function is_cookie(name) :- This is boolean function, which return true or false for cookies existence.

4) javascript function delete_cookie(name) :- This is a void function which is used to delete cookies. name param takes name of cookies which you want to delete.

<Script Language="javascript">

function set_cookie(name,value){
var name=name.toLowerCase();

function is_cookie(name){
var name=name.toLowerCase();
var str=document.cookie.indexOf(name+"=");
return true;
return false;

function get_cookie(name){
var name=name.toLowerCase();
var str="";
var cStr=document.cookie.split(";");
for(var i=0;iif(cStr[i].indexOf(name)>=0){
return str;

function delete_cookie(name){
var name=name.toLowerCase();


Wednesday, October 15, 2008

Dynamic Array Collection Using Flex

We can create dynamic Array Collection in flex using following code.

var ob:Object;
var n:String = "Name";
var a:String = "Address";
var ar:ArrayCollection = "";

ob = new Object();

ob[n] = "Ar";
ob[a] = "xyz, UK";

ar = new ArrayCollection();

It binds data into array just like.

arrayCollection = [{Name:'Ar',Address:'xyz, UK'}];

setPropertyIsEnumerable() is use to hide ArrayCollection item. which we can use like.


After using above method we can hide array collection item.

Tuesday, October 14, 2008

Javascript Trim Function Problem

There is no function to trim string in javascript. We can use following user define function to trim string using javascript. Mainly we need three type of trim function which we use in program.

Right Trim Javascript User Define function.

function rightTrim(str)
return str.replace(/\str+$/,"");

Left Trim Javascript User Define function.

function leftTrim(str)
return str.replace(/^\str+/,"");

Trim javascript function for both left and right side.

function trim(str)
return str.replace(/^\str+|\str+$/g,"");