Skip to content

Commit e349b33

Browse files
author
LAPTOP\Stefán Ö Sigmundsson
committed
Committing.
0 parents  commit e349b33

36 files changed

+2997
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/*
3+
Copyright © 2016, 2018 eMedia Intellect.
4+
5+
This file is part of eMI FileUpload Library.
6+
7+
eMI FileUpload Library is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
eMI FileUpload Library is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with eMI FileUpload Library. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
namespace Emi\FileUpload;
22+
23+
use Exception;
24+
25+
class InvalidErrorCodeException extends Exception
26+
{
27+
public function __construct(string $message, int $code = 0, Exception $previous = null)
28+
{
29+
parent::__construct($message, $code, $previous);
30+
}
31+
}
32+
?>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/*
3+
Copyright © 2016, 2018 eMedia Intellect.
4+
5+
This file is part of eMI FileUpload Library.
6+
7+
eMI FileUpload Library is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
eMI FileUpload Library is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with eMI FileUpload Library. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
namespace Emi\FileUpload;
22+
23+
use Exception;
24+
25+
class NoFilesUploadedException extends Exception
26+
{
27+
public function __construct(string $message, int $code = 0, Exception $previous = null)
28+
{
29+
parent::__construct($message, $code, $previous);
30+
}
31+
}
32+
?>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/*
3+
Copyright © 2016, 2018 eMedia Intellect.
4+
5+
This file is part of eMI FileUpload Library.
6+
7+
eMI FileUpload Library is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
eMI FileUpload Library is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with eMI FileUpload Library. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
namespace Emi\FileUpload;
22+
23+
use Exception;
24+
25+
class NoTemporaryDirectoryException extends Exception
26+
{
27+
public function __construct(string $message, int $code = 0, Exception $previous = null)
28+
{
29+
parent::__construct($message, $code, $previous);
30+
}
31+
}
32+
?>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/*
3+
Copyright © 2016, 2018 eMedia Intellect.
4+
5+
This file is part of eMI FileUpload Library.
6+
7+
eMI FileUpload Library is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
eMI FileUpload Library is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with eMI FileUpload Library. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
namespace Emi\FileUpload;
22+
23+
use Exception;
24+
25+
class UnknownErrorCodeException extends Exception
26+
{
27+
public function __construct(string $message, int $code = 0, Exception $previous = null)
28+
{
29+
parent::__construct($message, $code, $previous);
30+
}
31+
}
32+
?>

Library/File.php

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
/*
3+
Copyright © 2016, 2018 eMedia Intellect.
4+
5+
This file is part of eMI FileUpload Library.
6+
7+
eMI FileUpload Library is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
eMI FileUpload Library is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with eMI FileUpload Library. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
namespace Emi\FileUpload;
22+
23+
class File
24+
{
25+
private $error = null;
26+
private $mediaType = null;
27+
private $name = null;
28+
private $size = null;
29+
private $temporaryName = null;
30+
31+
private $destinationName = null;
32+
33+
public function __construct(string $name, string $mediaType, int $size, string $temporaryName)
34+
{
35+
$this->name = $name;
36+
$this->mediaType = $mediaType;
37+
$this->size = $size;
38+
$this->temporaryName = $temporaryName;
39+
}
40+
41+
public function GetDestinationName() : string
42+
{
43+
if ($this->destinationName === null)
44+
{
45+
return $this->temporaryName;
46+
}
47+
else
48+
{
49+
return $this->destinationName;
50+
}
51+
}
52+
53+
public function GetMediaType() : string
54+
{
55+
return $this->mediaType;
56+
}
57+
58+
public function GetName() : string
59+
{
60+
return $this->name;
61+
}
62+
63+
public function GetSize() : int
64+
{
65+
return $this->size;
66+
}
67+
68+
public function GetTemporaryName() : string
69+
{
70+
return $this->temporaryName;
71+
}
72+
73+
public function Move(string $destination) : bool
74+
{
75+
if (move_uploaded_file($this->temporaryName, $destination . '/' . basename($this->GetDestinationName())))
76+
{
77+
return true;
78+
}
79+
else
80+
{
81+
return false;
82+
}
83+
}
84+
85+
public function SetDestinationName(string $destinationName) : void
86+
{
87+
$this->destinationName = $destinationName;
88+
}
89+
}
90+
?>

0 commit comments

Comments
 (0)