コード例 #1
1
ファイル: upload.php プロジェクト: LolcatsV2/Pomf
/**
 * Reorganize the $_FILES array into something saner
 *
 * @param  $_FILES
 * @return array
 */
function refiles($files)
{
    $result = array();
    $files = diverse_array($files);
    foreach ($files as $file) {
        $f = new UploadedFile();
        $f->name = $file['name'];
        $f->mime = $file['type'];
        $f->size = $file['size'];
        $f->tempfile = $file['tmp_name'];
        $f->error = $file['error'];
        // 'expire' doesn't exist neither in $_FILES nor in UploadedFile;
        // commented out for future implementation
        //$f->expire   = $file['expire'];
        $result[] = $f;
    }
    return $result;
}
コード例 #2
0
ファイル: Component.php プロジェクト: questrom/formulaic
 function getSubmissionPart($val)
 {
     # Get the relevant parts of $_POST/$_FILES,
     # converting $_FILES with diverse_array if need be.
     return $val->ifOk(function ($v) {
         return Result::ok([isget($v->post[$this->name]), isget($v->files[$this->name])]);
     })->ifOk(function ($data) {
         return Result::ok([is_array($data[0]) ? $data[0] : [], is_array($data[1]) ? diverse_array($data[1]) : []]);
     })->listValidate($this->minItems, $this->maxItems, $this->name, $this->items);
 }
コード例 #3
-1
ファイル: posts.php プロジェクト: rolies/cityHelp
$subs = substr($category, 0, 1) . substr($type, 0, 1);
$check = mysql_query("SELECT * FROM post WHERE (post_id REGEXP '^{$subs}')");
$num = 0;
while ($row = mysql_fetch_object($check)) {
    $data = explode("-", $row->post_id);
    $data = $data['1'];
    if ($num < $data) {
        $num = $data;
    }
}
$post_id = $subs . "-" . ($num + 1);
//PICTURE START HERE
include 'function.php';
$dir = "gallery/";
$allowedExt = array("jpg", "jpeg", "png");
$file = diverse_array($_FILES['picture']);
$img = array();
$idx = 1;
foreach ($file as $array) {
    $ext = explode(".", $array['name']);
    $ext = strtolower(end($ext));
    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $mime = finfo_file($finfo, $array['tmp_name']);
    if ($mime == $array['type'] && in_array($ext, $allowedExt)) {
        $filename = basename($array['name']);
        if (move_uploaded_file($array['tmp_name'], $dir . $filename)) {
            array_push($img, $post_id . "-" . $idx . "." . $ext);
            echo "Sukses";
        } else {
            echo "Gagal";
        }