₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,193 members, 8,420,748 topics. Date: Friday, 05 June 2026 at 10:28 AM

Toggle theme

Code To Upload Image - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingCode To Upload Image (1544 Views)

1 Reply (Go Down)

Code To Upload Image by kelechiodo(op): 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, "."wink, 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"wink;

//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"wink;


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(op): 4:54pm On Jul 18, 2009
Dear Lojik, thanks alot. You really helped.
1 Reply

I Need Help On How To Upload Image To A Windows Based ApplicationPros, Help Me Upload Image With JavaUrgent! Php Upload Image Script234

Google's G-africa Initiative For Nigerian DevelopersWrite Code To Implement Polygon In JavaMobile Web Application, Beginners Guide.