Skip to content
Newer
Older
100644 39 lines (31 sloc) 935 Bytes
4c789e7 @mislav Initial import of PHP/GD image uploader
authored Jul 23, 2007
1 <?php
2 require_once 'image.php';
77972d5 @mislav updated messaging system; iframe upload
authored Jul 24, 2007
3 require_once 'Zend/Json.php';
4c789e7 @mislav Initial import of PHP/GD image uploader
authored Jul 23, 2007
4
5 $dir = './images/';
6 UploadedImage::setDirectory($dir);
7
77972d5 @mislav updated messaging system; iframe upload
authored Jul 24, 2007
8 $response = array(
9 'directory' => $dir,
10 'failed' => array(),
11 'saved' => array(),
12 );
13
4c789e7 @mislav Initial import of PHP/GD image uploader
authored Jul 23, 2007
14 foreach($_FILES['images']['name'] as $i => $name) {
15 if (!$_FILES['images']['size'][$i]) {
77972d5 @mislav updated messaging system; iframe upload
authored Jul 24, 2007
16 $response['failed'][] = array($name,
17 UploadedImage::getErrorMessage($_FILES['images']['error'][$i]));
4c789e7 @mislav Initial import of PHP/GD image uploader
authored Jul 23, 2007
18 continue;
19 }
20
21 $image = new UploadedImage('images', $i);
77972d5 @mislav updated messaging system; iframe upload
authored Jul 24, 2007
22 $filename = $image->path;
23 $filename_thumb = $dir . $image->name . '-thumb.' . $image->extension;
24 $image->resize(140, 78)->saveAs($filename_thumb);
25
4c789e7 @mislav Initial import of PHP/GD image uploader
authored Jul 23, 2007
26
77972d5 @mislav updated messaging system; iframe upload
authored Jul 24, 2007
27 ob_start();
28 include '_image.tpl.php';
29 $response['saved'][] = ob_get_clean();
4c789e7 @mislav Initial import of PHP/GD image uploader
authored Jul 23, 2007
30 }
31
77972d5 @mislav updated messaging system; iframe upload
authored Jul 24, 2007
32 # header('Content-type: text/plain');
33 # header('Location: ' . $_SERVER['HTTP_REFERER']);
34 ?>
35 <script type="text/javascript">
36 var data = <?= Zend_Json::encode($response) ?>;
37 parent.processResponse(data)
38 </script>
Something went wrong with that request. Please try again.