arunpatal Posted December 31, 2012 Share Posted December 31, 2012 (edited) Hello everyone... I am able to upload the image to server but how can i save the image name to database in field call product_image1 ... here is uploading script <?php if (isset($_FILES["product_image1"])){ $allowedExts = array("jpg", "jpeg", "gif", "png"); $extension = end(explode(".", $_FILES["product_image1"]["name"])); if ((($_FILES["product_image1"]["type"] == "image/gif") || ($_FILES["product_image1"]["type"] == "image/jpeg") || ($_FILES["product_image1"]["type"] == "image/png") || ($_FILES["product_image1"]["type"] == "image/pjpeg")) && ($_FILES["product_image1"]["size"] < 1024000) && in_array($extension, $allowedExts)) { if ($_FILES["product_image1"]["error"] > 0) { echo "Return Code: " . $_FILES["product_image1"]["error"] . "<br>"; } else { echo "Upload: " . $_FILES["product_image1"]["name"] . "<br>"; echo "Type: " . $_FILES["product_image1"]["type"] . "<br>"; echo "Size: " . ($_FILES["product_image1"]["size"] / 1024000) . " kB<br>"; echo "Temp file: " . $_FILES["product_image1"]["tmp_name"] . "<br>"; if (file_exists("upload/" . $_FILES["product_image1"]["name"])) { echo $_FILES["product_image1"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["product_image1"]["tmp_name"], "upload/" . $_FILES["product_image1"]["name"]); echo "Stored in: " . "upload/" . $_FILES["product_image1"]["name"]; } } } else { echo "Invalid file"; }} ?> Here is form form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1" enctype="multipart/form-data"> <input type="file" name="product_image1" value="" size="32" /> <input type="submit" value="Add Product" /> </form> Edited December 31, 2012 by arunpatal Quote Link to comment https://forums.phpfreaks.com/topic/272532-saving-name-to-database/ Share on other sites More sharing options...
BrettHartel Posted December 31, 2012 Share Posted December 31, 2012 (after connecting to a database using mysqli)... mysqli_query($link, "UPDATE Picture SET PictureName='$_FILES["product_image1"]["name"]' is that what you are looking for? Quote Link to comment https://forums.phpfreaks.com/topic/272532-saving-name-to-database/#findComment-1402281 Share on other sites More sharing options...
arunpatal Posted December 31, 2012 Author Share Posted December 31, 2012 (after connecting to a database using mysqli)... mysqli_query($link, "UPDATE Picture SET PictureName='$_FILES["product_image1"]["name"]' is that what you are looking for? GOT IT WORKED.......... THANKS MAN HAPPY NEW YEAR Quote Link to comment https://forums.phpfreaks.com/topic/272532-saving-name-to-database/#findComment-1402290 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.