upload.php
<?php
$host = 'localhost';
$user = 'root';
$pw = '';
$db = 'thepillar';
$pic = $_GET['pic'];
$ext = $_GET['ext'];
mysql_connect($host,$user,$pw);
mysql_select_db($db);
$handle = fopen($pic, "rb");
$img = fread($handle, filesize($pic));
fclose($handle);
$pic = base64_encode($pic);
$sql = "insert into infopics values(null,'$pic','$ext');";
mysql_query($sql) or die('Bad Query at '.mysql_error());
echo "Success! You have inserted your picture!";
?>
In the code above I am fetching $pic from my uploader.php page where I use
<input type="file" name="pic">
The problem here is that fopen() cannot execute its function because by using $_GET['pic'] it only retrieves the filename of the image that was chosen from the other page.
is there a way that I can retrieve the whole file path so that fopen can function?
use
$_FILES["nameOfFileControl"]["tmp_name"]
to get path of file
I think you need to review your concept of file and file upload. Please Read From Here. Its basics