0

Possible Duplicate:
JavaScript: Upload file
Uploading a file with html, javascript, and php

So I am trying to get my upload file code to work better. If someone could show me a simple way to upload a file, that could help me simplify my code, where it only uses javascript and PHP.

EDIT: If I could get a simple block of code in javascript and php then i could figure out the rest. I just cant find any good simple code snippets that shows the form, input, validate input, post to server, etc.

var myPatentOtherBrowseContainer = document.createElement('input');
            myPatentOtherBrowseContainer.name = 'myPatentOtherBrowseContainer';
            myPatentOtherBrowseContainer.id = 'myPatentOtherBrowseContainer';
            myPatentOtherBrowseContainer.type = 'file';
            myPatentOtherBrowseContainer.multiple = 'multiple';
            myPatentOtherBrowseContainer.size = '60';

this is just part of the code.

BTW, javascript is part of the code so it should be a tag!

8
  • PHP Manual: Handling file uploads Commented Sep 19, 2011 at 19:54
  • Please do not repost questions. And I'd like to know what the person who upvoted this question was thinking - if anything. Commented Sep 19, 2011 at 19:55
  • It has been edited! no one gave me time to edit it. Commented Sep 19, 2011 at 19:56
  • It the javascript side that I need the most help. Read the post! Commented Sep 19, 2011 at 19:57
  • 2
    What do you mean by the Javascript side? What is the JavaScript supposed to do? For a basic example on how to build an upload form, see my link above (the "POST Upload" section) Commented Sep 19, 2011 at 19:58

1 Answer 1

0

You want to use <input type="file" name="myFile"> and then you get access to that file through $_FILE['myFile']

Look through this tutorial, you can make the filefetching phpscript be called through AJAX if needed.

EDIT:

You pointed out you want help with the javascript part. I suggest you use jQuery to simplify any AJAX call through jQuerys .post() function.

You can read up on that here

Sign up to request clarification or add additional context in comments.

4 Comments

I can't use jQuery my boss wont allow it. That's why i said javascript and not the framework jQuery. Sorry, should have been more descriptive.
Well, jQuery is only used to help with things, AJAX is still viable. Take a look at w3schools
Yeah I know.. its my boss that doesn't. W3school wont help already looked. thanks though
Well either you dont use AJAX and reload the site to catch the post or use it and catch it async. Cant have it both ways, make sure to tell your boss that :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.