Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,363 members, 7,957,977 topics. Date: Wednesday, 25 September 2024 at 06:25 AM |
Nairaland Forum / Science/Technology / Programming / Code To Upload Image (1475 Views)
I Need Help On How To Upload Image To A Windows Based Application / Pros, Help Me Upload Image With Java / Urgent! Php Upload Image Script (2) (3) (4)
Code To Upload Image by kelechiodo(m): 3:36pm On Jul 09, 2009 |
I am using php to design a website. Now, I'm looking for help on either php or java code that will help me to upload image. The image is to appear on a form, just like WAEC and JAMB own. Please can anyone help. |
Re: Code To Upload Image by lojik(m): 10:24pm On Jul 09, 2009 |
<!-- html form to upload your image --> <form method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> <input type="file" name="uploaded_image" id="uploaded_image" /> </form> //example PHP code to receive and save picture from d above form: $fileName = $_FILES['uploaded_image']['name']; $tmpName = $_FILES['uploaded_image']['tmp_name']; $pixDir = "./the_folder_you_will_be_saving_pictures_to/"; // get the file extension first $ext = substr(strrchr($fileName, ".", 1); // and now we have to specify the path and filename to save as $filePath = $pixDir . $_POST["member_id"] . '.' . $ext; //member id is ur unique identifier for each member //move the file to the new folder //move the file to the new folder $result = move_uploaded_file($tmpName, $filePath); if(!$result) die("could not save picture" //set the path to the file in you database so you can use it to fetch the pix later $query = "UPDATE memberTable SET image_path = '".$filePath ."' WHERE member_id = ".$_POST["member_id"]; $result = mysql_query($query); if(!$result) die("could not save picture" The codes above were modified for you from Alumnia opensource portal available at http://www.afrisoft.org for free. it was taken from the edit.php file in the alumnia root directory. you can download Alumnia free to see the entire picture upload/display code. |
Re: Code To Upload Image by BigStar1(m): 4:15pm On Jul 10, 2009 |
thanks bross |
Re: Code To Upload Image by kelechiodo(m): 4:54pm On Jul 18, 2009 |
Dear Lojik, thanks alot. You really helped. |
(1) (Reply)
Article On Andela's First Female Fellow / IT Training In IBADAN / Do You Need A Backend Developer (PHP Or Laravel)
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 8 |