thefollower Posted November 27, 2007 Share Posted November 27, 2007 Like myspace how does it "upload" the images I got a form to give it a try but was wondering as I am using local host I want to test it by uploading to my own hard drive as such... but unfamiliar on 2 things... 1) where should it be stored in the htdocs directory precisely? 2) how do sites like myspace etc with hundreds of pictures on their server's know which image is related to which profile ? Is it possible to test on local host? Or will i have to buy a real server firstly? Any help here is much appreciated! Quote Link to comment Share on other sites More sharing options...
revraz Posted November 27, 2007 Share Posted November 27, 2007 If it was me, I would keep the images in the same folder or under the users profile folder, called images. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted November 27, 2007 Share Posted November 27, 2007 you would name the image with the users id... to have their profile picture thats wat im doing now Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 27, 2007 Share Posted November 27, 2007 Do you have a database? 1) It should be stored where every you feel the best place is. Personally I store uploaded images in a folder called "images" (Separate from default web page images) 2) The database for "MySpace" stores each image along with lots more information, such as: - image filename - image owner id - image location - image upload date - image album id - uploader IP address and probably much more. This is so they can associate each image with each user. Quote Link to comment Share on other sites More sharing options...
thefollower Posted November 27, 2007 Author Share Posted November 27, 2007 Right well im lost though cos then the names would be like: - image filename - image owner id - user name cat45thefollower.jpg But how can you make a script to extract userid to load the correct image.. i can extract names from strings but from a image file in a directory ? is that possible? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 27, 2007 Share Posted November 27, 2007 you don't extract the information from the filename of the image. It comes from information already stored in the database when the user signed up. Quote Link to comment Share on other sites More sharing options...
thefollower Posted November 27, 2007 Author Share Posted November 27, 2007 You've lost me =/ lol sos Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 27, 2007 Share Posted November 27, 2007 Files are uploaded as binaries with a secondary cluster of information that is associated wtih them such as size, file type, dates etc. this is stored in an array called $_FILES (check defined superglobals on php.net) You process the form via multi-type encrypt with post this passes via binary you deal with the binary on the second page, most servers will actually take the binaries and the file type adn store it in a temporary folder (PHP does this), then from taht temp folder you can do what you wish with it. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 27, 2007 Share Posted November 27, 2007 OK, first when a user signs up, he/she is assigned a number from the database. The number is what relates everything to this person. Say the user was given the number 100. When they upload an image, you will place 100 into the database along will the image filename. When you want to get an image relating to the person, you don't search for the image, but instead you search for the number 100, and that will give you every image that that person uploaded, since every image the person uploaded has the number 100 associated to it, and that 100 is associated to the user from the time of registration. Quote Link to comment Share on other sites More sharing options...
thefollower Posted November 28, 2007 Author Share Posted November 28, 2007 Right so you have to make a table: UserID | FileName And then i call up the info to and do like: <img src="<?=$Filename?>" id="Shape1" align="top" alt="" border="0" width="141" height="187"> Sort of like that? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 28, 2007 Share Posted November 28, 2007 yeah. But you will have at least 2 tables. users: userID | firstName | lastName images: fileID | ownerID | fileName Here is a basic way to do it: <?php session_start(); include 'db.php'; $query = "SELECT * FROM images where ownerID = '{$_SESSION['id']}'"; $sql = mysql_query($sql); while($row = mysql_fetch_array($sql)){ echo '<img src="'.$row['fileName'].'" id="Shape1" align="top" alt="" border="0" width="141" height="187">'; } ?> Any number in the ownerID (images table) column will match ONLY ONE number in the userID (users table) BUT ownerID can have an infinite amount of the same number WHERE AS userID MUST be unique. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.