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
https://forums.phpfreaks.com/topic/241444-uploading-file-to-imageshak/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.