$php_mysql$ Posted July 8, 2011 Share Posted July 8, 2011 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.