Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 16:06

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Upload picture with jquery or ajax with multiple fields

Discussion on Upload picture with jquery or ajax with multiple fields within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
mlukac89's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
Upload picture with jquery or ajax with multiple fields

Hi

I need to know how i can make form to upload picture without submiting form and get picture path in form field to insert in database here is code

so i need button next to image field "SELECT" and when i press select to choose picture from computer, image get uploaded and i get path im image field like C:\xampp\htdocs\images\users\imageblabla.jpg so i can save it into dataabse.

form html :

HTML Code:
<form action="" method="POST">
	<table width="100%" cellpadding="5" cellspacing="5" border="0" style="border:1px solid #919191;">
		<tr>
			<td width="200">Ime : </td><td><input type="text" name="ime"></td>
		</tr>
		<tr>
			<td>Prezime : </td><td><input type="text" name="prezime"></td>
		</tr>
		<tr>
			<td>Datum rođenja : </td><td><input type="text" name="dob"></td>
		</tr>
		<tr>
			<td>Mjesto rođenja : </td><td><input type="text" name="mjestorodjenja"></td>
		</tr>
		<tr>
			<td>Ime oca : </td><td><input type="text" name="imeoca"></td>
		</tr>
		<tr>
			<td>Ime majke : </td><td><input type="text" name="imemajke"></td>
		</tr>
		<tr>
			<td>Adresa : </td><td><input type="text" name="adresa"></td>
		</tr>
		<tr>
			<td>Image: </td><td><input type="text" name="image"></td>
		</tr>
		<tr>
			<td colspan="2"><input type="submit" name="dodaj" value="Dodaj"></td>
		</tr>
	</table>
</form>

form php :

PHP Code:
if (isset($_GET['page']) && $_GET['page'] == 'korisnici' && !empty($_GET['page']) && isset($_GET['action']) && !empty($_GET['action']) && $_GET['action'] == 'dodaj') {

    if (isset(
$_POST['dodaj'])) {
        if (isset(
$_POST['ime']) && 
            isset(
$_POST['prezime']) && 
            isset(
$_POST['dob']) && 
            isset(
$_POST['mjestorodjenja']) && 
            isset(
$_POST['imeoca']) && 
            isset(
$_POST['imemajke']) &&
            isset(
$_POST['adresa']) &&
            isset(
$_POST['image'])) {

            
$ime             $general->safe_input($_POST['ime']);
            
$prezime         $general->safe_input($_POST['prezime']);
            
$dob             $general->safe_input($_POST['dob']);
            
$mjestorodjenja $general->safe_input($_POST['mjestorodjenja']);
            
$imeoca         $general->safe_input($_POST['imeoca']);
            
$imemajke         $general->safe_input($_POST['imemajke']);
            
$adresa         $general->safe_input($_POST['adresa']);
            
$image             $general->safe_input($_POST['image']);

            
$dodaj $users->admin_add_user($ime$prezime$dob$mjestorodjenja$imeoca$imemajke$adresa$image);

            if (
$DBH->lastInsertId()) {
                echo 
'Korisnik dodan.';
                
header('Refresh: 2; url=index.php?page=korisnici');
            }
            else
            {
                echo 
'Korisnik nije dodan, došlo je do greške. Molimo pokušajte ponovno.';
            }

        }
    } 
mlukac89 is offline  
Old 01/31/2015, 18:19   #2
 
MrDami123's Avatar
 
elite*gold: 56
Join Date: Oct 2010
Posts: 3,409
Received Thanks: 1,219
Quote:
Originally Posted by mlukac89 View Post
upload picture without submiting form
Trigger a function which uploads the image with a POST request after the user have sucessfully selected an image from his computer.
MrDami123 is offline  
Old 01/31/2015, 21:44   #3
 
mlukac89's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 473
Received Thanks: 104
can u give me some example because i was never do something like this and in jquery
mlukac89 is offline  
Old 02/01/2015, 23:29   #4
 
MrDami123's Avatar
 
elite*gold: 56
Join Date: Oct 2010
Posts: 3,409
Received Thanks: 1,219
You can do this probably with PHP too. Else you just write a small javascript function which calls your PHP function.

The best way in case it actually to google. You would have your answer yesterday at 13:15.
MrDami123 is offline  
Reply


Similar Threads Similar Threads
[B] Website's - Coding ->HTML|CSS|PHP|JAVASCRIPT|AJAX|JQUERY|MYSQL .. [S] money
03/24/2016 - Coders Trading - 69 Replies
http://www.bilder-upload.eu/upload/64fbfa-14130921 09.png ->>> skype: alex03036 ->>>
jQuery/Ajax neue Elemente SlideIn
08/09/2014 - Web Development - 4 Replies
Servus, ich hoffe ihr könnt mir helfen. Ich würde gerne, dass neue Elemente die ich per Ajax in meiner .php Datei erzeuge hinter ein Div reingeslidet kommen. Das erzeugen der Divs hinter dem Div habe ich zwar geschafft, jedoch den Slide nicht so wie ich will. Undzwar geht es darum Bestellungen hinzuzufügen und nach jeder Bestellung soll ein Hinweis (in einem Div) von der .php Datei kommen ob das geklappt hat. Dieser Hinweis soll per SlideIn() eingeblendet werden und bestehen bleiben. Nun...
Proffesional Front-end (Html,css,js (jquery,ajax)), Back-End (PHP) solutions
04/14/2014 - Coders Trading - 1 Replies
Hello, i offer you Professional Front-end, Back-end solutions. I have more than 3 years of PHP/HTML/CSS experience About 2 years of Javascript developing MVC, OOP, Jquery, AJAX are my best friends. I work with Codeigniter (back-end) and Foundation (Front-end) Frameworks. I`m working with Joomla CMS too.
Jquery Ajax PHP HTML Java PLEASE HELP ME!
05/04/2011 - Main - 0 Replies
Hallo Com, http://ralphwhitbeck.com/content/binary/JQuery_lo go_color_onwhite.png Ich suche jemanden der mich in skype adden kann und mir hilft, ich habe ein javascript (das ich hier nicht veröffentliche) und möchte da ein PHP script einbauen. Aber es geht nicht so wie ich es will bitte helf mir jemand persöhnlich skype ist am besten
Jquery/Ajax [FRAGE]
02/07/2011 - Metin2 Private Server - 23 Replies
Ich wollte mal fragen... ich habe ne webseite und möchte im content bereich etwas anzeigen lassen ohne die seite neu laden zu müssen also es gibt zum beispiel



All times are GMT +1. The time now is 16:07.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.