Storing images in a folder but managed by MySql
Hello.
I have a script that stored an image via mysql.
Is it possible to store images in a folder but managed by MySql?
Is it possible to store them into a folder?
Also, is there a way to link or display that image like in a php code or html?
Can we link to it like http:// or something similar?
Thanks.
Zain - [email protected]
InfoDoma
http://www.infodoma.com
Zain posted this at 08:24 — 21st January 2002.
They have: 9 posts
Joined: Jan 2002
Hello.
Here is the mysql dump file.
:
<?php
CREATE TABLE content (
id mediumint(8) NOT NULL auto_increment,
category tinyint(4) DEFAULT '0',
date timestamp(14),
body_text text NOT NULL,
title tinytext NOT NULL,
binary_file blob NOT NULL,
PRIMARY KEY (id)
);
?>
How can we add a table to it that will store the location of a file, and be accesed again to be viewed in html or php code, uploaded and stored via the following php code, but not currently the technique used to upload the image]:
<?php
if (is_uploaded_file($userfile)) {
copy($userfile, \"C:\apache\htdocs\file\\");
} else {
echo \"Possible file upload attack\: filename '$userfile'\";
}
/* ...or... */
move_uploaded_file($userfile, \"C:\apache\htdocs\file\\");
?>
in such a way that it is processed through mysql, but the image is stored in a folder on the server, and not directly in the mysql database itself. So that only the location of the image on the server is stored in mysql automatically,
The image is currently called using code like:
domain.com/graphic_view.php?id=4
where id=4 is the id of the binary file stored in the mysql database.
At the moment the file is drectly stored and not some folder using the following code:
<?php
$query = \"INSERT INTO $user_tablename VALUES(NULL,'$category', NULL,'$enabled_url_text', '$title', '$imagedata')\";
$result = mysql_query($query);
if(!$result) error_message(sql_error());
?>
and is displayed using the code [in the graphic_view.php file which is used to display the image at the moment]:
<?php
while ($row = mysql_fetch_array($news_query)){
$idnum=$row[ \"id\"];
$graphic=$row[ \"binary_file\"];
?>
Any ideas? Again, short of it, currently the image is directly stored in the mysql database, and I want only the image location to be stored in the mysql database, and image stored in a folder?
Thanks.
Zain - [email protected]
InfoDoma
http://www.infodoma.com
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.