Reaper0167 Posted January 26, 2009 Share Posted January 26, 2009 i found this basic upload script. it works, very simple. but when the picture is uploaded to mysql,,, it creates its own row,, a new row... how would i have it upload to the row of whoever is signed in at that time? here is the simple little script i found online. also,,, what is the "rb" in the line below?? <?php $filename = $_FILES['file']['tmp_name']; if (($handle = fopen($filename, "rb"))) { // rb???? $stream = fread($handle, filesize($filename)); fclose($handle); unlink($filename); $type = $_FILES['file']['type']; $dbh = mysql_connect("---------", "----------", "----------"); mysql_select_db("--------", $dbh); $qstr = sprintf("INSERT INTO `members` (`type`, `stream`) VALUES ('%s', '%s')", mysql_real_escape_string($type), mysql_real_escape_string($stream)); echo "Picture added to database."; mysql_query($qstr, $dbh) or die(mysql_error()); } ?> better yet,,, instead of uploading the image in the same row of the user that is signed in. Would it be better to create a new table for all the images and then somehow link images to users that upload them.. Can i do that??? Quote Link to comment Share on other sites More sharing options...
redarrow Posted January 27, 2009 Share Posted January 27, 2009 read this please , remember uploading files can cause hack attack, must specify the correct file. extension allowed to be uploaded. http://uk3.php.net/manual/en/features.file-upload.post-method.php yes create a new database field called pictures example ((database normalization helps.)) database field name. pictures id int not null auto_increment primary key users_id int not null <<<match this the same as the users login database id name. picture_name varchar(100) not null date_added int not null Quote Link to comment Share on other sites More sharing options...
haku Posted January 27, 2009 Share Posted January 27, 2009 This section of the forum is not for 3rd party scripts. Please post in the '3rd party script' section of the forum. Quote Link to comment Share on other sites More sharing options...
Reaper0167 Posted January 27, 2009 Author Share Posted January 27, 2009 Could anyone point me in the right direction for a decent upload script. And then also linking a member back to what he/she uploaded. After a user uploads some pictures(picture, name, description of pic), they could go to a page to see just what they uploaded. Or they could also just view all the pics that all the users uploaded. Is this just way to difficult to do....When a user uploads a picture they get to pick from a list of categories that the picture would go in. Quote Link to comment Share on other sites More sharing options...
haku Posted January 27, 2009 Share Posted January 27, 2009 That's not a script, thats a dozen scripts. Quote Link to comment Share on other sites More sharing options...
Reaper0167 Posted January 27, 2009 Author Share Posted January 27, 2009 sorry,,,,, but any suggestions for a good starting point. i guess it would be something similar to ebay. 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.