Possible Duplicate:
JavaScript: Upload file Uploading a file with html, javascript, and php
So I am try开发者_开发知识库ing 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!
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
精彩评论