Javascript cannot read local files for security reasons, so we can't send the data using AJAX.
However you can POST a standard HTML form, and set the form target to be an invisible iframe on the page. This iframe can then use server side code to handle the upload.
If your reason to use AJAX is because you'd like a progress bar as the file is uploading, using this method you can use a server-side static variable to store the progress of the file upload, then use AJAX to make a simple, timed request to another HTTP page which just returns the upload progress.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…