Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Monitorr/assets/php/upload.php /
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
57 lines (44 sloc)
1.82 KB
This file contains 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 | |
| $target_dir = "../data/usrimg/"; | |
| $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); | |
| $uploadOk = 1; | |
| $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); | |
| $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); | |
| $rawfile = $_FILES["fileToUpload"]["name"]; | |
| echo "<div id='uploadreturn'>"; | |
| if($check !== false) { | |
| echo "File " . $rawfile . " is an image: " . $check["mime"] ; | |
| echo "<br>"; | |
| $uploadOk = 1; | |
| } | |
| else { | |
| echo "<div id='uploaderror'>"; | |
| echo "ERROR: " . $rawfile . " is not an image or exceeds the webserver’s upload size limit."; | |
| echo "</div>"; | |
| $uploadOk = 0; | |
| } | |
| if (file_exists($target_file)) { | |
| echo "<div id='uploaderror'>"; | |
| echo "ERROR: " . $target_file . " already exists."; | |
| echo "</div>"; | |
| $uploadOk = 0; | |
| } | |
| if ($uploadOk == 0) { | |
| echo "<div id='uploaderror'>"; | |
| echo "ERROR: " . $rawfile . " was not uploaded."; | |
| echo "</div>"; | |
| } | |
| else { | |
| if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], strtolower($target_file))) { | |
| echo "<div id='uploadok'>"; | |
| echo "File ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded to: " . strtolower($target_file) ; | |
| echo "</div>"; | |
| } | |
| else { | |
| echo "<div id='uploaderror'>"; | |
| echo "ERROR: there was an error uploading " . $rawfile; | |
| echo "</div>"; | |
| } | |
| } | |
| echo "</div>"; | |
| ?> |