Upload image and add image path on db
Hello there!
I have a form that add some information on mysql db but i need a way to upload an image with this form too and the path of the image to be inserted on the db. I don't know how to do it. Can you help me please? I didn't create any field for image bcz i don;t know what type of field it should be and i did not have any db field for image bcz i don;t know how it should be. I mention that i don;t want to upload the image on my db; i need only the path of the image. On the edit page i need to show the image with image tag <img src.... /> and the same field with browse option for edit it. Thank you very much and hoping that you can help me! -----------edit----------- Thank you for your reply and helping me. I have made those changes but i dunno what variable i should put on sql insert statement for the img field. What i have now is: $sql = "INSERT INTO lajme (KatLajmeID, LajmeEmri, LajmeLink, LajmeIntro, LajmeTxt, LajmeAktiv, LajmeTag, LajmeVideo, LajmeImg) VALUES ('$KatLajmeID', '$LajmeEmri', '$LajmeLink', '$LajmeIntro', '$LajmeTxt', '$LajmeAktiv', '$LajmeTag', '$LajmeVideo', '$LajmeImg')"; // LajmeImg - is the image field on db // $LajmeImg - is the variable that i putted and didn't worked.I tried to use like image variable $file but it didn't worked too :( At form process i putted: include ('includes/uploader.class.php'); $uploader = new uploader(); // Setting properties then Uploading the image $uploader->destDir = "D:/Program Files/VertrigoServ/www/oldi/imazhet/artikuj/"; $uploader->upload($_FILES['image']); The form uploads the image correctly but it didn't insert the path on the db :(
5 Answers
Any Danger In Using Expired Amoxicillin Forum Cialis 20mg <a href=http://cialiviag.com>cialis</a> Cephalexin For Dental Infections Std Pills Online Cialis Generico E Legale
Posted: Ellgaibra 0 of 0 people found this answer helpful. Did you? Yes No
Hello there. I'm posting here again bcz i need a little help on the modification you did on script. You made the name to be generate automatically by base64. What i need is a way to make the name of the image like this:
its_real_name_base64Code In this way i'll have google readable images and unique id images. Can you help me on this please? Thank you! Posted: Kleidi 0 of 0 people found this answer helpful. Did you? Yes No
your code is not clear its not organised
if(isset($_POST['do_edit'])) { if(isset($_FILES['LajmeImg'])){ //upload here } } Posted: MacOS 0 of 0 people found this answer helpful. Did you? Yes No
Image Variable should be
$LajmeImg = $_FILES['image']['name']; Posted: xtremex 3 of 3 people found this answer helpful. Did you? Yes No Thank you xtremex for your reply. It worked thanks to you ;)
What i was looking around now is how to make autoname now. :( I changed the autoName variable to true but it didn't renamed the image on upload. Any help on this? Thank you ;) it seem the class has no autoName support The class that i have downloaded writtes at the top something like public $autoName = true; :( yes but in the source its not used :) this is an error from the coder And how to make it working? If i upload 2 different images with the same name, the last one will rewrite the first image :( now the class support this feature i made some changes on it just use autoName = true and then when save the name in mysql use $uploader->source['name'] to save the random name - now go the class downloading page agian Thank you very much Jooria. It works great thanks to you. It generates unique names now :D
Thanks! thank you my friend but i think the class owner will kill me if he know what i did, lol :) :P ... Eh, it's an open source and you can do what you need with it :P
we can use uploader class
now you should enctype the form <form method=\"post\" enctype=\"multipart/form-data\">and add the file input <input name=\"image\" type=\"file\" size=\"20\" />and when click \'Vazhdo\' you sould use this php code include (\'uploader.class.php\'); $uploader = new uploader(); // Setting properties then Uploading the image $uploader->destDir = \"images/\"; $uploader->upload($_FILES[\'image\']); and in your datebase table you should make new field to store the img name to get it from the server and look at the class function to make the edit page by delete and other function Posted: MacOS 2 of 2 people found this answer helpful. Did you? Yes No |
© Advanced Web Core. All rights reserved