anthelo Posted August 19, 2012 Share Posted August 19, 2012 Hello, i need some help from the experts. This is the code where im uploading the image on the server <script type="text/javascript" > $(function(){ var btnUpload=$('#upload'); var status=$('#status'); var uploadingfile; new AjaxUpload(btnUpload, { action: 'lib/image-store.php', name: 'uploadfile', onSubmit: function(file, ext){ if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){ // extension is not allowed alert('Only JPG, PNG or GIF files are allowed'); return false; } status.text('Uploading...'); }, onComplete: function(file, response){ //On completion clear the status alert('Image Uploaded'); //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> Here is the code where i submit the data on the server <script type="text/javascript"> $("#CSubmit").click(function(e) { e.preventDefault(); var $form = $("#CForm"), fname = $form.find('input[name="fname"]').val(), sname = $form.find('input[name="sname"]').val(), email = $form.find('input[name="email"]').val(), phone = $form.find('input[name="phone"]').val(), uid = $form.find('input[name="uid"]').val(), description = $form.find('textarea#description').val(), url = $form.attr('action'); $.ajaxSetup({async: false}); $.post('lib/user-store.php', { fname: fname, sname: sname, email: email, phone: phone, description: description, uid: uid }, function(data) { if (data == 'ok') { $('#div1').hide(); $('#div2').show(); alert(uploadingfile); } }); return; }); </script> Both of the are working, what i want to do is when uploading an image (code 1) to get the file name and submit them on mysql like the rest of the data (code 2) Regards Quote Link to comment Share on other sites More sharing options...
phpassassin Posted August 20, 2012 Share Posted August 20, 2012 try using $_FILES , this array handled the uploaded file information. Quote Link to comment Share on other sites More sharing options...
anthelo Posted August 20, 2012 Author Share Posted August 20, 2012 thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.