SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    $_FILES and $_POST in one parameter

    Greetings! I know that $_POST, $_GET and $_FILES are different things, but is it possible to combine them $_post and $_file in java script? I want to validate the two user input in act_user.php.

    am i doing right?
    Code:
    			
    			parameters = 'fname='+document.getElementById('fname').value + '&' + 'lname='+document.getElementById('lname').value + '&' + 'id='+document.getElementById('stud_id').value+'&'+'gender='+document.getElementById('gender').value+'&'+'program='+document.getElementById('program').value+'&'+'file='+document.getElementById('file').value;
    		
    			xmlhttp.open('POST','FILE', 'act_user.php', true);
    			xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    			xmlhttp.send(parameters);
    			
    			
    	}
    I have input text fname, lname, gender, program and id.

  2. #2
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    No, you cannot upload files to your server like this. 'file='+document.getElementById('file').value will return nothing, as JavaScript isn't allowed to access file inputs (I think). You'll need to upload them the regular way, or using something like uploadify (http://www.uploadify.com/).

  3. #3
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    is there any way other than that?is it possible to put the same action in <form action= 'validation.here'> and the same action found in js?

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,183
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    You could use an iframe and direct the form target to it as seen in the following demo http://css-tricks.com/snippets/html/...-to-an-iframe/
    Blog/Portfolio | Evolution Xtreme | DFG Design | DFG Hosting | CSS-Tricks | Stack Overflow | Paul Irish
    Having lame problems with your code? Let us help by using a jsFiddle

  5. #5
    SitePoint Addict
    Join Date
    Dec 2011
    Posts
    221
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    thank you the suggestions, I'm trying now the iframe, it really works like javascript except for the space covered by the iframes tag. is there any way to just append it using javascript?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •