FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


HomeWatched TopicsRegisterSearchDirectory
FAQMemberlistUsergroupsLog inStoresItemsBank
Google

Reply to topic Page 1 of 1
Help please, this is recking my head....
Message  
Reply with quote
Post Help please, this is recking my head.... 
I know White Acid has kinda the same thing, but his solution will not work for me, What I have to do is POST a file and the word 'yes' to a server and then bring it back to me, the only way I know how to do this is Curl in php, but my script isn't working. Here it is:

Code:

<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
body
{background-color:#000000;}
table
{background-color:#990000;}
td
{background-color:#666666;}
font
{font-family:Verdana, Arial, Helvetica, sans-serif;
color:#FFFFFF;}
</style>
</head>

<body>
<table width="100%" border="0" cellspacing="5" cellpadding="5">
<?php
  $filething=$_FILES['file']['tmp_name'];
$part=$_POST['section'];
$lognam=$_SESSION['login_tis'];
$ips = $_SERVER['REMOTE_ADDR'];
  include("../dogs.inc.php");

   
   $url = "http://www.server2.com/index.php";
$ch = curl_init();   // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, "fileupload=$filething&xml=yes"); // add POST fields
$result = curl_exec($ch); // run the whole process
curl_close($ch);

if ($result)
{

echo "<font><br />We got<br /><br />";
echo $result;
echo '<br /><br />Back from Image Shack</font>';
   class RSSParser {

   var $insidelinks = false;
   var $tag = "";
   var $image_link = "";
   var $thumb_link = "";
   var $server = "";

   function startElement($parser, $tagName, $attrs) {
      if ($this->insidelinks) {
         $this->tag = $tagName;
      } elseif ($tagName == "LINKS") {
         $this->insidelinks = true;
      }
   }

   function endElement($parser, $tagName) {
      if ($tagName == "LINKS") {
         printf("<font>%s</font>",
            htmlspecialchars(trim($this->image_link)));
         $this->image_link = "";
         $this->thumb_link = "";
         $this->server = "";
         $this->insidelinks = false;
      }
   }

   function characterData($parser, $data) {
      if ($this->insidelinks) {
      switch ($this->tag) {
         case "IMAGE_LINK":
         $this->image_link .= $data;
         break;
         case "THUMB_LINK":
         $this->thumb_link .= $data;

         break;
         case "SERVER":
         $this->server .= $data;
         break;
      }
      }
   }
}

$xml_parser = xml_parser_create();
$rss_parser = new RSSParser();
xml_set_object($xml_parser,&$rss_parser);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = $result;
while ($data = $fp)
   $thexml = xml_parse($xml_parser, $data, $fp)
      or die(sprintf("XML error: %s at line %d",
         xml_error_string(xml_get_error_code($xml_parser)),
         xml_get_current_line_number($xml_parser)));
}
else
{
echo "<font>Did not POST</font>";

}

   if(@!file($thexml))
   {
            
         echo'
<tr>
<td colspan="3"><font>The URL is not a valid file you have the path '.$thexml.'';
echo '<br /></font></td>
</tr>';
   }         
   else
   {
   



   
   
   
         $sql = "INSERT INTO pics (pic,part,person,section,ip)
               VALUES ('$thexml','$part','$lognam','Pictures','$ips')";
         mysql_query($sql) or die("Can't execute query.");
   
   
         
         echo'
<tr>
<td colspan="3"><img src="thumb.php?pic='.$thexml.'" alt="Image is not an image!"/><font>Picture Added</font></td>
</tr>';
}



?>
<table width="100%" border="0" cellspacing="5" cellpadding="5">
   <form action="add2.php" method="post" enctype="multipart/form-data">
  <tr>
   <td width="50"><font>Section</font></td>
   <td width="40"><input name="section" type="text" size="40" /></td>
   <td><font>This is the section under which your picture will be displayed</font></td>
  </tr>
  <tr>
   <td width="50"><font>File</font></td>
   <td width="40"><input type="file" name="file" size="30"></td>
   <td><font>This is the file that you want to upload</font></td>
  </tr>
  <tr>
   <td colspan="3"><input style="width: 100px;" type="submit" value="host it!" ></td>
  </tr>
  </form>
</table>

</body>
</html>


So what should happen is: a user puts in the file, and then this script runs, it should Curl to the second server and then I get XML back with the link to the file, this script then parses the XML and I put it into my database, but it does not work.... Any ideas? Please...

View user's profile Send private message Visit poster's website
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  



Google

FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


Web Design by PlatinumShore.com & Web Hosting by TradeWebHosting.com