I am trying now to upload image into folder(images) and display filepath into table column to reference uploaded image. (example) image uploaded:(report.jpg) store image into folder(images) now create URL to image in table < img src="https://www.****.com/images/report.jpg" alt="" /> unfortunatley i have come up with which only stores the filename in the table (report.jpg)
<?php
if ($_POST["action"] == "Load") {
$folder = "images/";
move_uploaded_file($_FILES["filep"]["tmp_name"], "$folder".$_FILES["filep"]["name"]);
echo "<p align=center>File ".$_FILES["filep"]["name"]."loaded...";
$result = mysql_connect("**", "**", "**") or die ("Could not save image name Error: " . mysql_error());
mysql_select_db("testing") or die("Could not select database");
mysql_query("INSERT into links (hyper_links) VALUES('".$_FILES['filep']['name']."')");
if ($result) {
echo "Image name saved into database";
} else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
}
?>
<form action=sample.php method=post enctype="multipart/form-data">
<table border="0" cellspacing="0" align=center cellpadding="3" bordercolor="#cccccc">
<tr>
<td>File:</td>
<td><input type="file" name="filep" size=45/></td>
</tr>
<tr>
<td colspan=2>
<p align=center>
<input type=submit name=action value="Load"/>
</p>
</td>
</tr>
</table>
</form>