-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactions.php
87 lines (81 loc) · 2.74 KB
/
actions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* This is a prototype of the server side
*
*/
if($_GET['action'] == 'list'){
echo json_encode(
array(
'files' => array(
array(
'id' => 1, //mandatory
'type' => 'image', //mandatory
'src' => 'http://farm2.static.flickr.com/1233/1304237864_7a4aeb2bbd.jpg',
'category' => 'guitars',
'height' => '100',
'width' => '100',
'description' => "Description Test Lorem Ipsum",
),
array(
'id' => 2, //mandatory
'type' => 'image', //mandatory
'src' => 'http://t2.gstatic.com/images?q=tbn:ANd9GcRCNdcXr6Mn18kc069JtQFywX6oYr4O2LtleXsUC8iNiUaSmpjH',
'category' => 'guitars',
'height' => '100',
'width' => '100',
),
array(
'id' => 3, //mandatory
'type' => 'image', //mandatory
'src' => 'http://t2.gstatic.com/images?q=tbn:ANd9GcRCNdcXr6Mn18kc069JtQFywX6oYr4O2LtleXsUC8iNiUaSmpjH',
'category' => 'pianos',
'height' => '100',
'width' => '100',
'description' => "Description test",
),
)
)
);
}
if($_GET['action'] == 'upload'){
/*
* Save the file in database and filesystem with this info.
*
///// $_POST //////
array
'd' => string 'dafs' (length=4)
'category' => string 'rubros' (length=6)
'submit' => string 'Upload' (length=6)
///// $_FILES //////
array
'f' =>
array
'name' => string 'uploaded_image.png' (length=14)
'type' => string 'image/png' (length=9)
'tmp_name' => string '/tmp/phpcOZS6h' (length=14)
'error' => int 0
'size' => int 738062
*/
sleep(1);
/**
* File you just uploaded info
*/
echo json_encode(array(
'status' => 'success',
'file' => array(
'id' => 1000, //mandatory
'type' => 'image', //mandatory
'src' => 'http://farm2.static.flickr.com/1233/1304237864_7a4aeb2bbd.jpg',
'category' => 'drums',
'height' => '100',
'width' => '100',
'description' => "Description test",
)));
}
if($_GET['action'] == 'upload_with_error'){
//Image upload causes errors
echo json_encode(array(
'status' => 'error',
'errors'=> array('The file you want to upload is very large')
));
}