View Single Post
Old 04-24-2009, 11:00 PM  
SmokeyTheBear
►SouthOfHeaven
 
SmokeyTheBear's Avatar
 
Join Date: Jun 2004
Location: PlanetEarth MyBoardRank: GerbilMaster My-Penis-Size: extralarge MyWeapon: Computer
Posts: 28,609
actually the code above will work with any file but may not output the download url unless its a certain file because i didnt realise it gives a different format of download url depending on the filetype

what filetype do you plan on uploading ?

heres some code to upload an entire directory of images to zshare and it spits out the download links
Code:
<?php


foreach (glob("*.jpg") as $filename) {

$file = "$filename";
$description = "$filename";
$post_vars = array();
$post_vars['desc'] = "$description";
$post_vars['file'] = "@$file";


$url = 'http://dl084.zshare.net:3000/';

$return = http_post_form($url, $post_vars);
$ere = explode("zshare.net/image/",$return);
$sre = explode("/",$ere[1]);
$dlink = "http://www.zshare.net/image/$sre[0]";
echo "$dlink<br>";
}


function http_post_form($url, $vars) {
  $ch = curl_init();
  $timeout = 0; 
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);  
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); 
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
  $file_contents = curl_exec($ch);
  curl_close($ch);
  return $file_contents;
}


?>
__________________
hatisblack at yahoo.com
SmokeyTheBear is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote