Convert Code From Php To Vb.net

A Member? Please Login  
type your username and password to login
Date: October 11, 2008, 11:20 AM
248668 members and 147245 Topics
Latest Member: 9ja4laif
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Programming  |  Convert Code From Php To Vb.net
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: Convert Code From Php To Vb.net  (Read 640 views)
Kobojunkie
Convert Code From Php To Vb.net
« on: November 02, 2007, 11:20 PM »

Any PHP /ASP.NET guru in here to translate the code below to VB.NET /C#


<?php
   // PHP script to receive image data from Picnik via HTTP POST

   // Make sure we've been sent an image.  By default, the
   // image data goes into the "file" field, but we could
   // change that using the _export_field API parameter.
   if (!isset($_POST['file'])) {
      echo "Sorry, no image data was sent.";
      exit();
   }
   
   // Save the image to disk.  It'll go into the same directory as
   // this script.  You'D probably want to put it somewhere else in the
   // file system like a "/images" directory, or maybe even into a database.
   $image_data = $_POST['file'];
   $image_filename = "picnik_exported_file" . time() . rand(10000,99999) + ".jpg"
   file_put_contents( $image_filename, $image_data );   
   
   // Display a result to let the user know what happened.  You
   // might need to be smarter about how the $image_link variable is
   // built, depending on how your web server is set up.
   $image_link = dirname($_SERVER['PHP_SELF']) . "/" . $image_filename;
   echo "Your file was saved to $image_filename.<br/>";
   echo "You can find it at this URL: <a href='$image_link'>$image_link</a><br/>";
   echo "<img src='$image_link'>";
?>





<?php
   // PHP script to download image data from Picnik after we're given
   // a temporary URL via HTTP GET.

   // Make sure we've been sent an image url
   if (!isset($_GET['file'])) {
      echo "Sorry, no image URL was sent.";
      exit();
   }   
   $image_url = $_GET['file'];
   
   // Make sure that the image came from picnik.  We don't want anyone
   // sending us data we didn't ask for!
   if (0 !== stripos( $image_url, "http://www.picnik.com")) {
      echo "Sorry, the image URL doesn't seem right.";
      exit();      
   }
   
   // Download the image data from Picnik's servers
   $image_data = file_get_contents( $$image_url );
   if (FALSE === $image_data) {
      // Download failed ,  this shouldn't happen very often,
      // but you might want to put some retry logic in your app
      echo "Sorry, the image download failed.";
      exit();      
   }   
   
   // Save the image to disk.  It'll go into the same directory as
   // this script.  You'D probably want to put somewhere else in the
   // file system like a "/images" directory, or maybe even into a database.
   $image_filename = "picnik_exported_file" . time() . rand(10000,99999) + ".jpg"
   file_put_contents( $image_filename, $image_data );   
   
   // Display a result to let the user know what happened
   $image_link = dirname($_SERVER['PHP_SELF']) . "/" . $image_filename;
   echo "Your file was saved to $image_filename.<br/>";
   echo "You can find it at this URL: <a href='$image_link'>$image_link</a><br/>";
   echo "<img src='$image_link'>";
?>


skima (m)
Re: Convert Code From Php To Vb.net
« #1 on: November 06, 2007, 05:16 PM »

this itself is having error. $_POST['file']/ $_GET['file'] should be change to $_FILES['file'];
Kobojunkie
Re: Convert Code From Php To Vb.net
« #2 on: November 06, 2007, 05:34 PM »

Just translate it. I can take care of the errors mysel in vb.net but not in php
 Proposed Nigerian Software Developers Forum  G.i.s Geographic Information Systems   Visual Basic Sample Program "Talking Menu"  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 
Google
 
Web www.nairaland.com
Sections: TV/Movies (2) Music/Radio (2) Celebrities Job Talk Jobs/Vacancies (2) Career Talk Romance Books Politics Sports Fashion Travel
Health Schooling Religion General(2) Business Webmaster Programming Computers Phones Cars & Trucks

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.