inherit
112533
0
Dec 8, 2022 0:53:44 GMT -8
Luke
2,993
October 2007
darkzer0
|
Post by Luke on Dec 7, 2009 18:46:56 GMT -8
That depends, where would you like to move it? To a sub-directory?
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Dec 7, 2009 18:49:08 GMT -8
Directly to database if possible.. though I have no idea how to display them..
|
|
inherit
112533
0
Dec 8, 2022 0:53:44 GMT -8
Luke
2,993
October 2007
darkzer0
|
Post by Luke on Dec 7, 2009 18:52:51 GMT -8
Erm... I don't exactly understand what you are trying to do? Are you trying to add the image into the MySQL database? Not possible. When uploading the image it should be directly uploaded to the folder you want it to be in. The database, all it really does is store information on that image. (Date uploaded, file name, file location, user, etc.)
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Dec 7, 2009 18:56:25 GMT -8
Oh.. So i need to make a sub-directory, move it to there? then how does the mySQL get the information?
|
|
inherit
112533
0
Dec 8, 2022 0:53:44 GMT -8
Luke
2,993
October 2007
darkzer0
|
Post by Luke on Dec 7, 2009 18:59:46 GMT -8
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Dec 7, 2009 19:01:18 GMT -8
I know that But is "fname" or "uploaded_images" the sub-directory?
|
|
inherit
112533
0
Dec 8, 2022 0:53:44 GMT -8
Luke
2,993
October 2007
darkzer0
|
Post by Luke on Dec 7, 2009 19:02:15 GMT -8
fname would be the column in the database that stores the images file name, and uploaded_images would be the table in the database.
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Dec 7, 2009 19:08:39 GMT -8
... Then where does the sub-directory play in? And btw, do you have a method on how I could rename the file, as in example.png to 2141345.png ?
|
|
inherit
112533
0
Dec 8, 2022 0:53:44 GMT -8
Luke
2,993
October 2007
darkzer0
|
Post by Luke on Dec 7, 2009 19:13:47 GMT -8
If you are planning on storing images in different sub-directory's then I suggest you create a new column that stores the directory the image is in. For changing the image name, when it is uploaded and you are moving it that's when you would change the name. move_uploaded_file($_FILES['file']['tmp_name'], $newfilename)
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Dec 7, 2009 19:15:50 GMT -8
In lamen's terms please, lol.. and the second part would be like:
$newfilename = rand(0, 9999); move_uploaded_file($_FILES['file']['tmp_name'], $newfilename)
|
|
inherit
112533
0
Dec 8, 2022 0:53:44 GMT -8
Luke
2,993
October 2007
darkzer0
|
Post by Luke on Dec 7, 2009 19:51:24 GMT -8
Well first off if you don't know what I am talking about you should study the structure of a MySQL database. Google it.
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Dec 7, 2009 20:26:24 GMT -8
It's possible to store images directly to MySQL. Just not recommended, since it's a huge MySQL load and would possibly crash the server if the site got large enough.
Anyway:
SELECT `url` FROM `images` WHERE `user` = $user_id
When they upload a file: $url = '/images/' . rand(0, 9999) . '.' $extension; move temporary uploaded file to $url although I'd recommend replacing rand(0, 9999) to be something alphanumeric. INSERT INTO `images` (`user`, `url`) VALUES ($user_id, "$url")
|
|
inherit
16846
0
Nov 19, 2012 15:20:20 GMT -8
Chris
3,036
December 2003
cddude
|
Post by Chris on Dec 8, 2009 0:00:02 GMT -8
It's possible to store images directly to MySQL. Just not recommended, since it's a huge MySQL load and would possibly crash the server if the site got large enough. Anyway: SELECT `url` FROM `images` WHERE `user` = $user_id When they upload a file: $url = '/images/' . rand(0, 9999) . '.' $extension; move temporary uploaded file to $url although I'd recommend replacing rand(0, 9999) to be something alphanumeric. INSERT INTO `images` (`user`, `url`) VALUES ($user_id, "$url") Just since it wasn't mentioned in this post, make sure to also include a part of the script that checks to see if the file already exists and assigns a different random name until it doesn't exist. That way you don't have to worry about a file getting overridden. Pseudo code for above: (PHP styled, but not necessarily right names.) while(file_exists($rand_name)){ $rand_name = gen_new_rand_name(); } Just something like that.
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Dec 8, 2009 20:35:00 GMT -8
Okay.. so mySQL really isn't needed? besides using it in the member area?
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Dec 8, 2009 21:48:02 GMT -8
Definitely not. You should be storing the images flatfile, not in MySQL. For guests: *file is uploaded* *file is moved to permanent location* *permanent URL is output for the uploader*
The end.
|
|