I am trying to upload an image to server using PHP and the save inside a dir, and then returning the image url.
HTML:
First you need a multipart/form-data form for uploading. This is a must :)
The PHP part is fairly simple: This would result your file stored in "upload/{filename}" The main part you want to consider is how to get the filename and back to your write_string_to_database procedure, you could do a simple script after the upload page like
save_string_to_database("upload/" . $_FILES["file"]["name"]);
would do the trick.
0)
{
echo "Error: " . $_FILES["file"]["error"] . "
";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
}
}