shobhitjain Posted November 16, 2009 Report Share Posted November 16, 2009 (edited) hi guysThis code is working fineBut i don't wan't to access images via upload button.i just want to pass a defined value ,just when i click on the button it should take that value and upload that file.i have tried all combinations,but i am unable to find that where to put that path such that path provided by upload button can be replaced Please help<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"><head profile="http://gmpg.org/xfn/11"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>AJAX File Upload - Web Developer Plus Demos</title><script type="text/javascript" src="js/jquery-1.3.2.js" ></script><script type="text/javascript" src="js/ajaxupload.3.5.js" ></script><link rel="stylesheet" type="text/css" href="./styles.css" /><script type="text/javascript" > $(function(){ //var btnUpload=$('#upload'); var btnUpload=$('#upload'); var status=$('#status'); new AjaxUpload(btnUpload, { action: 'http://localhost/upload-file.php', name: 'uploadfile', onSubmit: function(file, ext){ if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){ // extension is not allowed status.text('Only JPG, PNG or GIF files are allowed'); return false; } }, onComplete: function(file, response){ //On completion clear the status status.text(''); //Add uploaded file to list if(response==="success"){ $('<li></li>').appendTo('#files').html('<img src="./uploads/'+file+'" alt="" /><br />'+file).addClass('success'); } else{ $('<li></li>').appendTo('#files').text(file).addClass('error'); } } }); });</script></head><body><input type="button" id="upload" /></body></html> Edited November 16, 2009 by Shobit Link to comment Share on other sites More sharing options...
Synook Posted November 16, 2009 Report Share Posted November 16, 2009 Where is the file you want to upload? Link to comment Share on other sites More sharing options...
shobhitjain Posted November 16, 2009 Author Report Share Posted November 16, 2009 (edited) it is on my hard-disk. I just need to provide path directly.not by clicking upload.i tried to change Above (#upload),i think it is getting the value when we click on the upload, Edited November 16, 2009 by Shobit Link to comment Share on other sites More sharing options...
justsomeguy Posted November 16, 2009 Report Share Posted November 16, 2009 The user has to provide the path, you cannot fill in the path through Javascript. Even if you manage to set the value of a file input element, it will not upload the file when you submit the form. The user has to select the file themselves in order for it to upload. Link to comment Share on other sites More sharing options...
jeffman Posted November 16, 2009 Report Share Posted November 16, 2009 Haven't we discussed this issue over and over? Link to comment Share on other sites More sharing options...
justsomeguy Posted November 16, 2009 Report Share Posted November 16, 2009 This and proxies, yes. Link to comment Share on other sites More sharing options...
shobhitjain Posted November 16, 2009 Author Report Share Posted November 16, 2009 (edited) Sir, this script is neither related to proxies nor XHR i just wanted to provide the path by myself. not the path via upload button..well this is resolved.Thanks and Regards. Edited November 16, 2009 by Shobit Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now