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!

Community
  • 1
  • 1
The_Brink
  • 2,649
  • 2
  • 16
  • 18
  • [PHP Manual: Handling file uploads](http://php.net/manual/en/features.file-upload.php) – Pekka Sep 19 '11 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. – Pekka Sep 19 '11 at 19:55
  • It has been edited! no one gave me time to edit it. – The_Brink Sep 19 '11 at 19:56
  • It the javascript side that I need the most help. Read the post! – The_Brink Sep 19 '11 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) – Pekka Sep 19 '11 at 19:58
  • Im using javascript to capture the file. – The_Brink Sep 19 '11 at 20:01
  • @The_Brink, you can take as much time as you need to write out the question you're asking. If you're too lazy to write it out nicely the first time, why should we be willing to answer your poorly-worded question? Please take some time and read through the [faq]. – zzzzBov Sep 19 '11 at 20:03
  • I figured I wrote enough.. sorry I didn't. Apparently Im working with code in javascript that people don't use very often. – The_Brink Sep 19 '11 at 20:09

1 Answers1

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

Artog
  • 1,132
  • 1
  • 13
  • 25
  • 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. – The_Brink Sep 19 '11 at 20:12
  • Well, jQuery is only used to help with things, AJAX is still viable. Take a look at [w3schools](http://www.w3schools.com/ajax/default.asp) – Artog Sep 19 '11 at 20:37
  • Yeah I know.. its my boss that doesn't. W3school wont help already looked. thanks though – The_Brink Sep 19 '11 at 20:40
  • 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 :) – Artog Sep 19 '11 at 20:43