If i submit using <input:text>, i can see the result but if i use <input:file>. i cannot upload.

jquery code;

// JavaScript Document
	 $(document).ready(function(){
	 
	 $("#myformcom").submit(function(){
	 		
			var str=$(this).serialize();
			//var result;
			
			$.ajax({
			type: "POST",
			url: "uploadfiles.php",
			data: str,
			success:function(msg)
			{
			
				$("#error").ajaxComplete(function(event,request,settings)
				{
				
					if(msg=='Successfully Submitted')
						{
							$(this).html(msg);
														
						}
					else{
							$(this).html(msg);
						}
						
					
						return true;			
				});
				
			}	
			});
			
			return false;
	 });
	 });

Recommended Answers

All 3 Replies

You cannot upload files via JavaScript and that is inclusive of AJAX. You could submit the form to a hidden iframe on the current page that will process the request. If you don't want to do that, I would recommend using Uploadify. It is a jQuery plug-in that incorporates Adobe Flash, enabling you to upload files via AJAX. Check it out @ http://uploadify.com.

thanks you very much

No problem!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.