I am currently working on a multiple image uploader with file directory. I am wanting to store file name inside my MySQL.
How can I store these variables(image names) inside my table through php ?
How can I retrieve the variables through php?
URL Generate by uploader:
- http://www.website.com/imageupload/index.php?i=4ff4bfd02c241.jpg
- http://www.website.com/imageupload/index.php?i=4ff4bfd02c242.jpg
Filename:
- 4ff4bfd02c241.jpg
- 4ff4bfd02c242.jpg
Table Name: urlimage
id: autoincrement
image_name
I am able to echo out the path and the name through this:
$images = explode(',', $_GET['i']);
$path = Configuration::getUploadUrlPath('medium', 'target');
foreach ($images as $image) {
echo '<div><p>' . $path . $image . '</p><img src="' . $path . $image . '" /></div>';
}
?>
Addiontally: you should think of using $_POST rather than $_GET becaus there’s a length limit depending on the browser (some of them cut URLs after 255 chars).
Also never put in userdefined content directly into you DB. You’ll need some kind of escaping ( http://php.net/manual/en/function.mysql-real-escape-string.php ).