Created
October 8, 2013 15:20
-
-
Save studentIvan/6886398 to your computer and use it in GitHub Desktop.
/test new GDPhoto testing
This file contains hidden or 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
<?php | |
class Common extends Services | |
{ | |
public static function test() | |
{ | |
try | |
{ | |
Process::load('GDPhoto'); | |
$uniqueId = 95; | |
$photo = new GDPhoto(); | |
$photo->upload('Filedata'); | |
$original = GDPhoto::calculateAbsolutePath($uniqueId, 'original', $photo->getExtension()); | |
$preview = GDPhoto::calculateAbsolutePath($uniqueId, 'preview', $photo->getExtension()); | |
$photo->save($original); | |
$photo->intellectualResizedByHeight(250); | |
$photo->save($preview, null, null, false, 95); | |
echo GDPhoto::calculateRelativePath($uniqueId, 'preview', $photo->getExtension()); | |
exit; | |
} catch (Exception $e) { | |
if ($e->getMessage() !== 'File Filedata did not uploaded') { | |
die($e->getMessage()); | |
} | |
} | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<script type="text/javascript" src="/js/jquery.min.js"></script> | |
<script type="text/javascript" src="/js/swfupload/swfupload.js"></script> | |
<script type="text/javascript" src="/js/swfupload/plugins/swfupload.queue.js"></script> | |
<link href="//yandex.st/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"> | |
<link href="/css/font-awesome.min.css" rel="stylesheet" media="screen"> | |
<script type="text/javascript" src="http://yandex.st/bootstrap/3.0.0/js/bootstrap.min.js"></script> | |
<style type="text/css"> | |
body { | |
margin: 10px; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Загрузка изображений</h1> | |
<button class="btn btn-default" style="padding: 0"> | |
<div id="uploadButton" style="background-color: transparent"></div> | |
</button> | |
<div id="status"></div> | |
<div id="images"></div> | |
<script> | |
var swfu; | |
function uploadSuccess(file, serverData) { | |
$('#images').append('<div style="display: inline-block;" class="unvisible"><img src="' + serverData + '"></div>'); | |
$('.unvisible').fadeOut(0).fadeIn(1000).removeClass('unvisible'); | |
} | |
function uploadComplete(file) { | |
$('#status').html($('<p>Загрузка завершена</p>')); | |
} | |
function uploadStart(file) { | |
//$('#status').html($('<p>Начата загрузка файла ' + file.name + '</p>')); | |
$('#status').html('<p><span class="icon-spinner icon-spin"></span> загрузка...</p>'); | |
return true; | |
} | |
function uploadProgress(file, bytesLoaded, bytesTotal) { | |
//$('#status').html($('<p>Загружено ' + Math.round(bytesLoaded/bytesTotal*100) + '% файла ' + file.name + '</p>')); | |
$('#status').html('<p><span class="icon-spinner icon-spin"></span> загрузка...</p>'); | |
} | |
function fileDialogComplete(numFilesSelected, numFilesQueued) { | |
$('#status').html($('<p>Выбрано ' + numFilesSelected + ' файл(ов), начинаем загрузку</p>')); | |
this.startUpload(); | |
} | |
window.onload = function () { | |
swfu = new SWFUpload({ | |
upload_url : "/test", | |
flash_url : "/js/swfupload/Flash/swfupload.swf", | |
button_placeholder_id : "uploadButton", | |
file_size_limit : "2 MB", | |
file_types : "*.jpg; *.png; *.jpeg; *.gif", | |
file_types_description : "Изображения", | |
file_upload_limit : "0", | |
debug: false, | |
button_width : 80, | |
button_height : 25, | |
button_text_left_padding: 10, | |
button_text_top_padding: 3, | |
button_text : "<span class=\"uploadButton\">Обзор...</span>", | |
button_text_style : ".uploadButton {font-size: 14px;}", | |
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT, | |
button_cursor: SWFUpload.CURSOR.HAND, | |
file_dialog_complete_handler : fileDialogComplete, | |
upload_success_handler : uploadSuccess, | |
upload_complete_handler : uploadComplete, | |
upload_start_handler : uploadStart, | |
upload_progress_handler : uploadProgress | |
}); | |
}; | |
</script> | |
</body> | |
</html> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment