Exemplo n.º 1
0
        $scr_target_dir = "../screenshots";
        $i = 1;
        foreach ($shots['error'] as $key => $error) {
            if ($error == UPLOAD_ERR_OK) {
                $tmp_name = $_FILES["shot"]["tmp_name"][$key];
                $name = basename($_FILES["shot"]["name"][$key]);
                $scr_id = $_POST['scr_id'][$i - 1];
                $ext = strrchr($name, ".");
                $dest_name = str_replace(" ", "", $apptitle) . "_" . $i . $ext;
                $i++;
                $destination = $scr_target_dir . "/" . $dest_name;
                chmod($tmp_name, 0777);
                //chmod($destination, 0777);
                if (move_uploaded_file($tmp_name, $destination)) {
                    $screenshot = new Screenshot();
                    $screenshot->id = $scr_id;
                    $screenshot->name = $dest_name;
                    $screenshot->app_id = $dis_app[0]->id;
                    $screenshot->update();
                    //
                } else {
                    echo "an error occured";
                    //header('Location: error.php');
                }
            }
        }
    }
    $session->setMessage("Your app has been updated.");
    header('Location: ../all_apps_listing.php');
} else {
}