Jump to content

uploading file to imageshak?


Recommended Posts

hey mates i got this bit of coding on here, i wanted to know how could i use it to my form and get the uploaded image link stored into my db structure?

 

<?php
preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $_FILES['foto']['name'], $ext);
$imagem_nome = md5(uniqid(time())) . "." . $ext[1];
rename($_FILES['foto']['tmp_name'], "/tmp/" . $imagem_nome);

$postData = array();
$postData['fileupload'] = "@/tmp/".$imagem_nome.";type=".$_FILES['data']['type'];
$postData['fileupload'] = "@/tmp/" . $imagem_nome;
$postData['submit']     = "Submit";
$postData['key']         = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$postData['rembar']     = "yes";
$postData['xml']        = "yes";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.imageshack.us/index.php");
curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 240);curl_setopt($ch, CURLOPT_POSTFIELDS, $postData );

$response = curl_exec( $ch );
curl_close($ch );

echo $response;
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"    
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>  
<title></title>
</head>
<body>    
<form action="imagem.php" method="post" enctype='multipart/form-data'>        
<input type="file" id="foto" name="foto" />        
<input type="submit" value="Enviar" />    
</form>
</body>
</html>

 

could someone tell me if this script really works too?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.