Created
July 16, 2012 14:44
-
-
Save battlejj/3123106 to your computer and use it in GitHub Desktop.
Uploadify and S3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> | |
<script type="text/javascript" src="js/uploadify/jquery.uploadify.v2.1.4.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
$('#uploadify').uploadify({ | |
uploader: 'js/uploadify/uploadify.swf', | |
folder: '/uploads', | |
multi: true, | |
auto: true, | |
script: 'upload.cfm?<cfoutput>#URLEncodedFormat(session.URLToken)#</cfoutput>', | |
fileDesc: 'Files', | |
fileExt: '*.*;', | |
onComplete: function(event, queueID, fileObj, response, data){ | |
$('#upload-result') | |
.css("display","none") | |
.html(response) | |
.slideDown('slow', function() { setTimeout('$("#upload-result").slideUp("slow");', 3000); }); | |
}} | |
); | |
}); | |
</script> | |
<link rel="stylesheet" type="text/css" href="css/style.css" /> | |
<link rel="stylesheet" type="text/css" href="js/uploadify/uploadify.css" /> | |
</head> | |
<body> | |
<h2 class="section-heading-1 border-1">Upload</h2> | |
<div class="section-mid border-1"> | |
<p>Click the "Browse" button to select the photos to upload. You may select multiple files to upload at the same time.</p> | |
<form action="?" method="post"> | |
<div> | |
<div id="uploadify"></div> | |
<div id="upload-result"></div> | |
</div> | |
</form> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
$(document).ready(function() { | |
$('#uploadify').uploadify({ | |
uploader: 'js/uploadify/uploadify.swf', | |
folder: '/uploads', | |
multi: true, | |
auto: true, | |
script: 'upload.cfm?<cfoutput>#URLEncodedFormat(session.URLToken)#</cfoutput>', | |
fileDesc: 'Files', | |
fileExt: '*.*;', | |
onComplete: function(event, queueID, fileObj, response, data){ | |
$('#upload-result') | |
.css("display","none") | |
.html(response) | |
.slideDown('slow', function() { setTimeout('$("#upload-result").slideUp("slow");', 3000);}); | |
} | |
}); | |
}); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="uploadify"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfset result = {status = "Success", class="alert-success", message="Image successfully uploaded."}> | |
<cftry> | |
<cfset perms = [ | |
{group="all", permission="read"}, | |
{id="[your canonical id here]", permission="full_control"} | |
]> | |
<cfset uploadAttempt = FileUpload("s3://[your bucket name here]/#form.filename#","form.fileData","*/*","MakeUnique")> | |
<cfset StoreSetACL("s3://[your bucket name here]/#uploadAttempt.serverFile#","#perms#")> | |
<cfcatch type="any"> | |
<cfset result = {status = "Failed upload.", class="alert-error", message="#cfcatch.Detail#"}> | |
<cflog type="Error" file="AmazonUploadError" text="[#cfcatch.type#] #cfcatch.message# [#cfcatch.Detail#]"> | |
</cfcatch> | |
</cftry> | |
<cfcontent reset="true"><cfoutput><div class="alert #result.class# border-1">#result.message#</div></cfoutput> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfset perms = [ | |
{group="all", permission="read"}, | |
{id="[your canonical id here]", permission="full_control"} | |
]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfset uploadAttempt = FileUpload("s3://[your bucket name here]/#form.filename#","form.fileData","*/*","MakeUnique")> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfset StoreSetACL("s3://[your bucket name here]/#uploadAttempt.serverFile#","#perms#")> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment