/** * getFile * * Returns the information for the file specified by parameter fullPath. * If the designated file is a directory the directory content is returned * as the children of the file. * * @param filePath File path string * @param rootDir Root directory * @param args HTTP QUERY-STRING arguments decoded. * @param status Receives the final result (200, 204 or 404). * * @return An array of 1 FILE_INFO object or NULL in case no match was found. **/ function getFile($filePath, $rootDir, $args, &$status) { if (file_exists($filePath)) { $files = array(); $uri = parsePath($filePath, $rootDir); $fileInfo = fileToStruct($uri->dirPath, $rootDir, $uri->filename, $args); if (!fileFilter($fileInfo, $args)) { if (property_exists($fileInfo, "directory")) { $fileInfo->children = getDirectory($filePath, $rootDir, $args, $status); $fileInfo->_EX = true; } // Don't give out details about the root directory. if ($filePath === $rootDir) { $fileInfo->name = "."; $fileInfo->size = 0; } $files[] = $fileInfo; } $status = $files ? HTTP_V_OK : HTTP_V_NO_CONTENT; return $files; } $status = HTTP_V_NOT_FOUND; return null; }
<?php include_once '../includePackage.php'; include_once 'upload.class.php'; session_start(); if (isset($_SESSION['login'])) { $uploader = new uploader(); if (isset($_POST['altAd'])) { if (isset($_FILES['adPic'])) { $file = $_FILES['adPic']; if (fileFilter($file, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png'), 500000)) { $temp = move_uploaded_file($file['tmp_name'], $_POST['adImg']); if (false == $temp) { mylog('fileerrer'); } } } if (isset($_POST['g_id'])) { pdoUpdate('ad_tbl', array('g_id' => $_POST['g_id']), array('id' => $_POST['altAd'])); } header('location:index.php?ad=1'); exit; } if (isset($_GET['infImgUpload'])) { $file = $_FILES['upfile']; $uploader->upFile(time() . rand(1000, 9999)); $inf = $uploader->getFileInfo(); $jsonInf = json_encode($inf, JSON_UNESCAPED_UNICODE); echo $jsonInf; if ('SUCCESS' == $inf['state']) { pdoInsert('inf_image_tbl', array('url' => $inf['url'], 'remark' => $inf['md5']), 'ignore');