wwfc_barmy_army Posted October 1, 2006 Share Posted October 1, 2006 Hi again guys.I'm here with another problem i have :)Ok, well i have a screenshot uploader on the admin of my site, and currently it uploads fine, although we need it add the link of where it's uploaded to, to the database but i'm not sure how to go about this (i'm still rather new to php), this is the code that uploads the image(a normal browse input box is further up the code) :[code] //Writes the screenshot to the serverif(move_uploaded_file($_FILES['screenshot']['tmp_name'], $target)){//Tells you if its all okecho "The file ".basename( $_FILES['uploadedfile']['name']). " has been uploaded.";}else {//Gives and error if its notecho "Sorry, there was a problem uploading your file.";} echo "<p>Site, '$name', has now been added";}[/code]Any advice on how i could get it to add it to the screenshot field in the site table? And also i would like to know if it's possible to add more than one screenshot in the seperate screen? Any advice, links, tutorials or code is appricated.Thanks for all your advice.Peter. Quote Link to comment Share on other sites More sharing options...
wwfc_barmy_army Posted October 1, 2006 Author Share Posted October 1, 2006 *Bump* :) Quote Link to comment Share on other sites More sharing options...
ponsho Posted October 1, 2006 Share Posted October 1, 2006 I dont know if i understood what you're trying to do, if its just to save the address of the screenshot your uploading into the database, just insert your $target variable into it.[code]$sql = "INSERT INTO yourtable (target) values ('$target')";mysql_query($sql);[/code] Quote Link to comment Share on other sites More sharing options...
wwfc_barmy_army Posted October 1, 2006 Author Share Posted October 1, 2006 Hello.That was pretty much what i wanted :) But one thing, currently the images are being entered into the database as:"../images/screenshots/image.jpg"But i want it as "images/screenshots/image.jpg", is there any way of doing this as when i try to display the image elsewhere on the site (not in the admin area) it messes up and i think it's because off the "../" in front of it.Can i do that?Thanks.Peter. Quote Link to comment Share on other sites More sharing options...
ponsho Posted October 2, 2006 Share Posted October 2, 2006 Yes you can do that just add this code before inserting into database[code]$targettodb = str_replace("../","",$target);[/code]So now the variable youre going to insert its the $targettodb Quote Link to comment Share on other sites More sharing options...
wwfc_barmy_army Posted October 2, 2006 Author Share Posted October 2, 2006 Brilliant! Thank for your help ponsho! :)Peter. 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.