This is quite a complex question, I'm sure. I've tried trawling the internet for some time now, but perhaps I'm not wording my question correctly when googling.
I have a HTML form that requests the following information;
I have already created a PHP script that captures the image and uploads it to a DIR, but what I'd also like to do is capture the text fields and then render the data (pic and text) and post to a webpage using formatting that I have set.
How easy is this to achieve?
PHP: http://www.mediafire.com/?bxze6j9kn048uzb
<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 512)) {
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
} else {
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"])) {
echo $_FILES["file"]["name"] . " already exists. ";
} else {
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
} else {
echo "Invalid file";
}
?>
Form: http://www.mediafire.com/?bao8n2uftu7ma34
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<input type="text" name="title" id="title" maxlength="50" size=40">
<input type="file" name="file" id="file" />
<textarea name="comments" maxlength="3000" cols="30" rows="12"></textarea>
<input type="image" src="/Images/upload_button.png" name="submit" value="Submit" />
</form>
Best,
Rob.
You need to save the data (text) somewhere like an database, and link the uploaded file to right text. Take a look at for example mongodb and mysql(which you probably have on you web hotel)
Mysql getting started http://net.tutsplus.com/tutorials/php/everything-you-need-to-get-started-with-mysql/ or http://www.w3schools.com/php/php_mysql_intro.asp