5
5
6
6
class BigUploadResponse
7
7
{
8
- /**
9
- * Temporary directory for uploading files.
10
- */
11
- const TEMP_DIRECTORY = '/tmp/ ' ;
12
-
13
- /**
14
- * Directory files will be moved to after the upload is completed.
15
- */
16
- const MAIN_DIRECTORY = '../files/ ' ;
17
-
18
8
/**
19
9
* Max allowed filesize. This is for unsupported browsers and
20
10
* as an additional security check in case someone bypasses the js filesize check.
@@ -28,13 +18,6 @@ class BigUploadResponse
28
18
*/
29
19
private $ tempDirectory ;
30
20
31
- /**
32
- * Directory for completed uploads.
33
- *
34
- * @var string
35
- */
36
- private $ mainDirectory ;
37
-
38
21
/**
39
22
* Name of the temporary file. Used as a reference to make sure chunks get written to the right file.
40
23
*
@@ -49,7 +32,6 @@ public function __construct()
49
32
{
50
33
$ tempDirectory = api_get_path (SYS_ARCHIVE_PATH );
51
34
$ this ->setTempDirectory ($ tempDirectory );
52
- $ this ->setMainDirectory (self ::MAIN_DIRECTORY );
53
35
$ this ->maxSize = getIniMaxFileSizeInBytes ();
54
36
}
55
37
@@ -105,26 +87,6 @@ public function getTempDirectory()
105
87
return $ this ->tempDirectory ;
106
88
}
107
89
108
- /**
109
- * Set the name of the main directory.
110
- *
111
- * @param string $value Main directory
112
- */
113
- public function setMainDirectory ($ value )
114
- {
115
- $ this ->mainDirectory = $ value ;
116
- }
117
-
118
- /**
119
- * Return the name of the main directory.
120
- *
121
- * @return string Main directory
122
- */
123
- public function getMainDirectory ()
124
- {
125
- return $ this ->mainDirectory ;
126
- }
127
-
128
90
/**
129
91
* Function to upload the individual file chunks.
130
92
*
@@ -288,30 +250,6 @@ public function finishUpload()
288
250
289
251
return json_encode (['errorStatus ' => 0 ]);
290
252
}
291
-
292
- /**
293
- * Basic php file upload function, used for unsupported browsers.
294
- * The output on success/failure is very basic, and it would be best to have these errors return the user to index.html
295
- * with the errors printed on the form, but that is beyond the scope of this project as it is very application specific.
296
- *
297
- * @return string Success or failure of upload
298
- */
299
- public function postUnsupported ()
300
- {
301
- $ name = $ _FILES ['bigUploadFile ' ]['name ' ];
302
- $ size = $ _FILES ['bigUploadFile ' ]['size ' ];
303
- $ tempName = $ _FILES ['bigUploadFile ' ]['tmp_name ' ];
304
-
305
- if (filesize ($ tempName ) > $ this ->maxSize ) {
306
- return get_lang ('UplFileTooBig ' );
307
- }
308
-
309
- if (move_uploaded_file ($ tempName , $ this ->getMainDirectory ().$ name )) {
310
- return get_lang ('FileUploadSucces ' );
311
- } else {
312
- return get_lang ('UplUnableToSaveFile ' );
313
- }
314
- }
315
253
}
316
254
317
255
$ sessionBigUpload = ChamiloSession::read ('bigupload ' , []);
@@ -358,7 +296,4 @@ public function postUnsupported()
358
296
ChamiloSession::write ('bigupload ' , $ sessionBigUpload );
359
297
}
360
298
break ;
361
- case 'post-unsupported ' :
362
- print $ bigUpload ->postUnsupported ();
363
- break ;
364
299
}
0 commit comments