Am using Shared server.
I can save external images using curl. But am unable to save the path and file info to mysql.
<form method="post" enctype="multipart/form-data">
<table>
<tr><td><b>URL: </b> </td><td><input type="**text**" name="url" id="url" size=40></td> </tr>
<tr><th colspan=2><p><input name="upload" type="submit" class="box" id="upload" value="Upload"></p></th></tr>
</table>
</form>
<?php
set_time_limit(0);
ini_set('display_errors',true);//Just in case we get some errors, let us know....
if (isset($_POST['upload']))
{
$url = $_POST['url'];
$dir = "./files/";
$fileName = $_FILES['url']['name'];
$fileSize = $_FILES['url']['size'];
$fileType = $_FILES['url']['type'];
$filePath = $dir . $fileName;
$ch = curl_init($url);
$fp = fopen ($local_file, 'w+');
$ch = curl_init($remote_file);
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_exec($ch);
curl_close($ch);
include ('db.php');
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
$query = "INSERT INTO upload2 (name, size, type, path ) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$filePath')";
mysql_query($query);
mysql_close($conn);
}
It is not working when I change input type to text from file.
I need to get file info and save to mysql server
Have a go with this: