Skip to content

Instantly share code, notes, and snippets.

@vmattila
Created March 8, 2013 13:14
Show Gist options
  • Save vmattila/5116378 to your computer and use it in GitHub Desktop.
Save vmattila/5116378 to your computer and use it in GitHub Desktop.
This gist includes test code for a possible bug in co-operation between Developr theme and https://github.com/blueimp/jQuery-File-Upload
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Developr modernizer -->
<script type="text/javascript" src="/js/libs/modernizr.custom.js"></script>
<!-- Developr jQuery 1.8.2 -->
<script type="text/javascript" src="/js/libs/jquery-1.8.2.min.js"></script>
<!-- @see https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin , UI Widget comes from the full jquery ui js -->
<script type="text/javascript" src="/javascript/datepicker/jquery-ui-1.9.1.custom.min.js"></script>
<script type="text/javascript" src="/javascript/jquery.fileupload.js"></script>
<script type="text/javascript" src="/javascript/jquery.iframe-transport.js"></script>
<!-- Developr theme setup -->
<script type="text/javascript" src="/js/setup.js"></script>
</head>
<body>
<form action="" method="POST">
<input type="file" name="file" id="fileField" />
<div id="progressBlock" style="display: none;">
<div>File is being uploaded, please wait...</div>
</div>
<script type="text/javascript">
$(function() {
$('#fileField').fileupload({
"dataType": 'json',
"url": "/upload-test.php",
"paramName": "f",
done: function(e, data) {
$('#fileField').show();
$('#progressBlock').hide();
if (data.result.success) {
alert("Upload Success");
} else {
alert('Upload failed: ' + data.result.error);
}
},
send: function(e, data) {
$('#fileField').hide();
$('#progressBlock').show();
}
});
});
</script>
</form>
</body>
</html>
<?php
// Simple server-side file to respond to file upload request
// Content-Type is text/html even the content is json.
// @see https://github.com/blueimp/jQuery-File-Upload/wiki/Setup (under header "Content-Type" negotiation)
Header("Content-Type: text/html");
echo json_encode(array('success' => true));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment