Jump to content

Please Help To Change Value Of Upload Button


shobhitjain
 Share

Recommended Posts

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 by Shobit
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...