Jump to content

[Solved]Image Upload to database?


wwfc_barmy_army

Recommended Posts

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 server
if(move_uploaded_file($_FILES['screenshot']['tmp_name'], $target))
{

//Tells you if its all ok
echo "The file ".basename( $_FILES['uploadedfile']['name']). " has been uploaded.";
}
else {

//Gives and error if its not
echo "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.
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.