Jump to content

Image uploading/inserting link into mysql


Sheets

Recommended Posts

Hello, i am making a very simple site to test how much i have learned. However i realized i need to simple it down and make it easier for the client side. Could anybody provide me with a link to a good tutorial where it shows how to upload a image to a certain directory then take that link and insert it into my database.

 

Thank you for your time :)

What are you having trouble with, specifically?  I ask because you simply need to be able to understand example 2 from: http://www.php.net/manual/en/features.file-upload.post-method.php and know how to write and execute an INSERT statement.

 

Do you have any code for us to look at?

<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.

$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
    echo "File is valid, and was successfully uploaded.\n";
} else {
    echo "Possible file upload attack!\n";
}

echo 'Here is some more debugging info:';
print_r($_FILES);

print "</pre>";

?>

 

I do not understand exactly what it is doing and why.  :-\

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.