We are trying to create a site for wallpapers so that would be somehow large files(2mb-5mb) so we'll be needing to store the images on the disk space instead in the database and only the paths to the database. So if you can give some ideas on how to do that (the method we know for now is creating a PHP script with the upload function and by manually selecting the images from the PC to be uploaded) unless you guys would have other suggestions. Tutorials will be much appreciated. Thanks a lot!
This is for the admins to add images not for the users. Note: we haven't developed any script so this is to get some ideas from you guys on what we can use with this, if none guess we will just go with the php script.
Generally databases are best for data and the file system is best for files. It depends what you're planning to do with the image though. If you're storing images for a web page then it's best to store them as a file on the server. The web server will very quickly find an image file and send it to a visitor.
In order to store images in a SQL database, you first need to save each plot image in a . png format.
Your form,
<form action="PHP_FILE_PATH.php" method="post" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit" name="submit" value="Upload" />
</form>
The PHP Part
<?php
if($_FILES['image']['name'])
{
$save_path="FOLDER_PATH_TO_SAVE_UPLOADED_IMAGE"; // Folder where you wanna move the file.
$myname = strtolower($_FILES['image']['tmp_name']); //You are renaming the file here
move_uploaded_file($_FILES['image']['tmp_name'], $save_path.$myname); // Move the uploaded file to the desired folder
}
$inser_into_db="INSERT INTO `database`.`table` (`folder_name`, `file_name`) VALUES('$save_path', '$myname'))";
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With