/    Sign up×
Community /Pin to ProfileBookmark

image upload with mysql?

this is a simple script i’m looking for.

i need to be able to upload a gif or jpg image to my server and have it post the image location to a mysql database so that later i can choose which image to display. make sense?

i can’t find a working one anywhere!

oh, and one tiny catch. my server has php safe mode on, but most scripts tend to work on it.

thank you in advance!
-Sheep

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@chazzyMar 03.2006 — YOu shouldn't be storing images in a database - makes for very poor performance. instead store the location in teh database.
Copy linkTweet thisAlerts:
@bokehMar 03.2006 — And what are you going to do once the details are stored in mysql?

What I am really asking is do you need a whole gallery script? Wht is the output going to be?
Copy linkTweet thisAlerts:
@jonraMar 03.2006 — Well, if you upload the images to an images directory on the server, and store the filename in the DB, you know where the files are. So pushing them to HTML is just like a normal image call. Get the info from the DB, and use something like this to spit it out:

[code=php]
while($row = mysql_fetch_array($result)){
echo "<img src="images/".$row['fileName']."">";
}
[/code]


Take Chazzy's advice and don't store those files in the DB, your site will turn into a total dog because of performance issues. If the file is on the server, and you have a set path where you store images, just store the file name in the DB - and you can write that into the DB at the same time you upload the photo. Upload the photo, if it was successful just run an insert query to update the DB.
Copy linkTweet thisAlerts:
@welshMar 03.2006 — i dont think he means upload it into the database, but rather the location of the specific image into the database.
Copy linkTweet thisAlerts:
@SaveSheepauthorMar 04.2006 — welsh is correct. i want to be able to upload an image to a directory, then put that location into a database...then you should be able to select which image you want to display. basically, i want to be able to change out three pictures on my website without having to go through editing the page. i want to login, delete the three existing pictures or so, upload new ones.
×

Success!

Help @SaveSheep spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...