i want make one form whit php , when users submit there urls , then my site give one picture form url and save on my host !
how can do that ?
thanks
Edited by BuffaloHELP, 09 May 2006 - 06:45 PM.
| |
|
Welcome to KnowledgeSutra - Dear Guest | |
Posted 10 May 2006 - 12:31 AM
farsiscript, on May 9 2006, 04:25 PM, said:
Posted 11 May 2006 - 01:23 PM
Edited by farsiscript, 11 May 2006 - 01:25 PM.
Posted 14 May 2006 - 02:46 PM
Posted 15 May 2006 - 12:20 AM
farsiscript, on May 14 2006, 01:28 PM, said:
<?php
function http_get_file($url) {
$url_stuff = parse_url($url);
$port = isset($url_stuff[‘port’]) ? $url_stuff[‘port’]:80;
$fp = fsockopen($url_stuff[‘host’], $port);
$query = ‘GET ‘ . $url_stuff[‘path’] . ” HTTP/1.0\n“;
$query .= ‘Host: ‘ . $url_stuff[‘host’];
$query .= “\n\n“;
fwrite($fp, $query);
while ($line = fread($fp, 1024)) {
$buffer .= $line;
}
preg_match(‘/Content-Length: ([0-9]+)/’, $buffer, $parts);
return substr($buffer, - $parts[1]);
}
?>
(take from http://damonparker.org/blog/2005/09/29/dow...ile-using-php/).Posted 17 May 2006 - 12:37 PM
<form action="sql.php" enctype="multipart/form-data" method="post"> <input type="file" name="image" /><br /> <input type="submit" name="upload" value="Upload" /> </form>
<?
// check wether the user pressed the upload button
if(isset($_POST['upload'])){
// below two lines connect to mysql and the mysql database
// change it according to your information
mysql_connect("localhost", "root", "");
mysql_select_db("img");
// below line opens the file chosen in the form for reading only
$file = fopen($_FILES['image']['tmp_name'], "r");
// then we read the file and add slashes to prevent errors when submitting to mysql
$image = addslashes(fread($file, filesize($_FILES['image']['tmp_name'])));
// inserts the null value as id, and our defined var $image to their corresponding cols.
// we use die(mysql_error()) as a error report if something screws up
mysql_query("insert into images values('null', '$image')") or die(mysql_error());
// if all goes well, echo the below line.
echo "image uploaded successfully";
}
?>
at 3 make view.php :<?
// changes our url id to the var $id
$id = $_GET['id'];
// connects to the database
//change info accordingly
mysql_connect("localhost", "root", "");
mysql_select_db("img");
// selects the binary data blob according to the id specified
// by our url
$result = mysql_query("select image from images where id = '$id'");
// tells php that contents of this page will be an image
header("(anti-spam-content-type:) image/jpeg");
// echoes our mysql query (echoes out the blob data)
echo mysql_result($result, 0);
?>
How To show images :Edited by moderator, 22 May 2012 - 06:13 AM.
Posted 19 May 2006 - 11:51 AM
Posted 21 May 2006 - 10:22 PM
Edited by farsiscript, 21 May 2006 - 10:24 PM.

0 members, 1 guests, 0 anonymous users