Jump to content
  • Advertisement
Sign in to follow this  
hyuen

[web] dojo file upload problem

This topic is 4149 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I'm trying to get dojo file upload working, but for some reason when I send the AJAX request through dojo.io.bind, the target script isn't getting the <input type="file"> information. Here's the javascript:
function uploadPicture(form) {
	
     var bindArgs = {
		url: "cp_menu_upload_pic.php",
		method: "post",
		error: function(type,error) {
			//restore the form
                        //...code goes here....
			result.innerHTML = error;		
			
		},
		load: function(type,data,event) {
			//restore the form
			//.....code goes here.......
			
			result.style.display = "block";
			
			if (t.indexOf("error") > -1) {
				//there's an error?
				result.innerHTML = data;
				
			} else {
				//we're given the filename so let's grab that
				dojo.byId("pic-filename").value = data;
				
				//generate some beautiful HTML
				var html = "";
				result.innerHTML = data;
			}
		},
		mimetype: "text/plain",
		formNode: form
	};
	
	dojo.io.bind(bindArgs);
	return false;
}
Yes, I did include dojo.require("dojo.io.IframeIO"); Here is the target script, cp_menu_upload_pic.php
    print_r($_POST);

    print_r($_FILES);

pretty straightforward, I'm just trying to see what I get. Here is the form HTML:
			<form id="pic-upload-form" onsubmit="return uploadPicture(this);" method="post" enctype="multipart/form-data">
			<tr>
				<td colspan="4">
					<label for="pic-file">Upload Picture: </label>
					<input type="file" name="pic-file" id="pic-file" size="30" />
					
				</td>
			</tr>
			<tr>
				<td colspan="3">
					<input type="submit" id="pic-upload" name="pic-upload" value="Upload"/>
					
				</td>
			</tr>
			<tr>
				<td colspan="4">
					<div id="pic-upload-result" style="display:none">
					
					
<input type="hidden" id="pic-filename" name="pic-filename" value="" />
</td> </tr> I feel like I'm missing something important but browsing through the internet I can't seem to pinpoint the problem. Any ideas? Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!