当前位置: 首页>>代码示例>>PHP>>正文


PHP Upload::moveFile方法代码示例

本文整理汇总了PHP中Upload::moveFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Upload::moveFile方法的具体用法?PHP Upload::moveFile怎么用?PHP Upload::moveFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Upload的用法示例。


在下文中一共展示了Upload::moveFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edituseradmin

 /**
  *Modifier un user
  */
 public function edituseradmin()
 {
     if (isset($_SESSION['user_id']) && $_SESSION['user_status'] == 2) {
         if (isset($_POST)) {
             if (isset($_POST['idUser'])) {
                 if (isset($_POST['first_name'])) {
                     $first_name = $_POST['first_name'];
                 } else {
                     $first_name = null;
                 }
                 if (isset($_POST['last_name'])) {
                     $last_name = $_POST['last_name'];
                 } else {
                     $last_name = null;
                 }
                 if (isset($_POST['email'])) {
                     if ($this->coreCheckEmail($_POST['email'])) {
                         $email = $_POST['email'];
                     } else {
                         $messageFlash = 'Wrong email adress. Please try again.';
                         $this->coreSetFlashMessage('error', $messageFlash, 4);
                         header("location:" . PATH_HOME . "admin/edituser/" . $_POST['idUser']);
                         exit;
                     }
                 }
                 if (isset($_POST['BirthDateSaved'])) {
                     $birth_date = $_POST['BirthDateSaved'];
                 } elseif (isset($_POST['birth_day']) && isset($_POST['birth_month']) && isset($_POST['birth_year'])) {
                     $birth_date = $_POST['birth_day'] . "/" . $_POST['birth_month'] . "/" . $_POST['birth_year'];
                 } else {
                     $birth_date = null;
                 }
                 if (isset($_POST['location'])) {
                     $location = $_POST['location'];
                 } else {
                     $location = null;
                 }
                 if (isset($_POST['skills'])) {
                     $skills = $_POST['skills'];
                 } else {
                     $skills = null;
                 }
                 if (isset($_POST['description'])) {
                     $description = $_POST['description'];
                 } else {
                     $description = null;
                 }
                 if (isset($_POST['school'])) {
                     $school = $_POST['school'];
                 } else {
                     $school = null;
                 }
                 if (isset($_POST['work'])) {
                     $work = $_POST['work'];
                 } else {
                     $work = null;
                 }
                 $id = $_POST['idUser'];
                 if (!empty($_FILES['userPicture']['name'])) {
                     $file = new Upload($_FILES['userPicture']['name'], $_FILES["userPicture"]["tmp_name"], 'assets/img/user_pp/', '');
                     if ($file->extControl()) {
                         if ($file->moveFile()) {
                             $userPicture = $file->setNom();
                             $lastId = $this->model->insertUserPicture($userPicture);
                         } else {
                             // fichier non déplacé
                             define("TITLE_HEAD", "An error occur.");
                             $messageFlash = 'An error occur. Please try again.';
                             $this->coreSetFlashMessage('error', $messageFlash, 3);
                             header("location:" . PATH_HOME . "admin/edituser/" . $id);
                             exit;
                         }
                     } else {
                         // Extension non autorisée
                         define("TITLE_HEAD", "An error occur.");
                         $messageFlash = 'Invalid file extension. Please try again.';
                         $this->coreSetFlashMessage('error', $messageFlash, 3);
                         header("location:" . PATH_HOME . "admin/edituser/" . $id);
                         exit;
                     }
                 } else {
                     if (isset($_POST['userPictureSaved'])) {
                         // TODO
                         // Supprimer l'ancienne photo
                         $userPicture = $_POST['userPictureSaved'];
                         $lastId = $this->model->insertUserPicture($userPicture);
                     } else {
                         $lastId = null;
                     }
                 }
                 if (!$this->model->update_profile($id, $first_name, $last_name, $birth_date, $email, $location, $description, $skills, $school, $work, $lastId)) {
                     // Si pas de données updaté
                     define("TITLE_HEAD", "An error occur.");
                     $messageFlash = 'An error occur. Please try again.';
                     $this->coreSetFlashMessage('error', $messageFlash, 3);
                     header("location:" . PATH_HOME . "admin/edituser/" . $id);
                     exit;
//.........这里部分代码省略.........
开发者ID:Totoyor,项目名称:Volunteers,代码行数:101,代码来源:AdminController.php

示例2: catch

    $fileSize = $upload->getFileSize();
    $mimeType = $upload->getMimeType();
    // Print the upload file's information
    print "Original File Name: {$origFileName}<br>\n";
    print "File Extension: {$fileExt}<br>\n";
    print "Mime Type: {$mimeType}<br>\n";
    print "File Size: {$fileSize}<br>\n";
    // Create a destination and name for the file
    $destFilePath = 'test.' . $fileExt;
    // This is not a bulletproof security measure, but at least it prevents our badscript.php
    if ($fileExt == 'php') {
        print "Stop trying to hack me!";
        exit;
    }
    // Move that file to the destination
    $upload->moveFile($destFilePath);
    // Provide a link to that destination
    print "<a href='{$destFilePath}' target='_blank'>Click here to view uploaded file</a><br>\n";
    // If that file was a jpg or gif image, print an image tag displaying that file
    if ($fileExt == 'jpg' || $fileExt == 'gif' || $fileExt == 'png') {
        print "<p><img src='{$destFilePath}' alt='uploaded image'></p>\n";
    }
} catch (UploadExceptionNoFile $e) {
    print "No file was uploaded.<br>\n";
} catch (UploadException $e) {
    $code = $e->getCode();
    $message = $e->getMessage();
    print "Error: {$message} (code={$code})<br>\n";
}
?>
</body>
开发者ID:bryanesmond,项目名称:fileupload,代码行数:31,代码来源:uploadHandler.php

示例3: edit


//.........这里部分代码省略.........
                         for ($i = 0; $i < count($event_categories); $i++) {
                             //$idEvent = $lastId;
                             $idCategory = $event_categories[$i];
                             $this->model->editCategories($idCategory, $idEvent);
                         }
                     } else {
                         if (isset($_POST['categoriesSave']) && !empty($_POST['categoriesSave'])) {
                             $idCategory = $_POST['categoriesSave'];
                             $this->model->editCategories($idCategory, $idEvent);
                         }
                     }
                     if (isset($_POST['missions'])) {
                         for ($i = 0; $i < count($event_missions); $i++) {
                             if ($_POST['missions'][$i] !== '') {
                                 $missions = $event_missions[$i];
                                 $nbVolunteer = $nb_volunteer[$i];
                                 $this->model->insertMissions($idEvent, $missions, $nbVolunteer);
                             }
                         }
                     }
                     if (!empty($_POST['missionsSave'])) {
                         for ($i = 0; $i < count($_POST['missionsSave']); $i++) {
                             if ($_POST['missionsSave'][$i] !== '') {
                                 $idMission = $_POST['idMissionsSave'][$i];
                                 $missions = $_POST['missionsSave'][$i];
                                 $nbVolunteer = $_POST['nbVolunteerSave'][$i];
                                 $this->model->editMissions($idEvent, $missions, $nbVolunteer, $idMission);
                             }
                         }
                     }
                     if (!empty($_FILES['coverPicture']['name'])) {
                         $file = new Upload($_FILES['coverPicture']['name'], $_FILES["coverPicture"]["tmp_name"], 'assets/img/events/uploads/', '');
                         if ($file->extControl()) {
                             if ($file->moveFile()) {
                                 if ($file->resizeFile()) {
                                     $coverPicture = $file->setNom();
                                     $this->model->insertCoverPicture($idEvent, $coverPicture);
                                 } else {
                                     $coverPicture = $file->setNom();
                                     $this->model->insertCoverPicture($idEvent, $coverPicture);
                                 }
                             }
                         }
                     } else {
                         if (isset($_POST['coverPictureSave']) && !empty($_POST['coverPictureSave'])) {
                             $coverPicture = $_POST['coverPictureSave'];
                             $this->model->insertCoverPicture($idEvent, $coverPicture);
                         }
                     }
                     if (!empty($_FILES['media'])) {
                         for ($i = 0; $i < count($_FILES['media']['name']); $i++) {
                             $name = $_FILES['media']['name'][$i];
                             $tmp_name = $_FILES["media"]["tmp_name"][$i];
                             $media = new Upload($name, $tmp_name, 'assets/img/events/uploads/', '');
                             if ($media->extControl()) {
                                 if ($media->moveFile()) {
                                     if ($media->resizeFile()) {
                                         $picture = $media->setNom();
                                         $this->model->insertMediaPicture($idEvent, $picture);
                                     } else {
                                         $picture = $media->setNom();
                                         $this->model->insertMediaPicture($idEvent, $picture);
                                     }
                                 }
                             }
                         }
开发者ID:Totoyor,项目名称:Volunteers,代码行数:67,代码来源:EventController.php

示例4: mkdir

 }
 require "classes/upload.php";
 if (!file_exists("banners/{$log_user_id}")) {
     mkdir("banners/{$log_user_id}", 0755);
 }
 $files_array = array();
 $files_array['fileName'] = $_FILES['banner']['name'];
 $files_array['fileType'] = $_FILES['banner']['type'];
 $files_array['fileSize'] = $_FILES['banner']['size'];
 $files_array['file_tmp_name'] = $_FILES['banner']['tmp_name'];
 $files_array['fileErrors'] = $_FILES['banner']['error'];
 $upload = new Upload($files_array, '1572864', $log_user_id);
 //$fileArray = $upload->getFileArray();
 $regex = "/^.*\\.(jpg|jpeg|png|gif)\$/i";
 if (count($upload->checkFile($regex)) == 0) {
     $moveit = $upload->moveFile("", "/banners");
     if ($moveit == true) {
         $query = $db->query("UPDATE members SET banner='{$moveit}' WHERE username='{$log_uname}' AND id='{$log_user_id}' LIMIT 1");
         require "classes/img_resize.php";
         $img = new ResizeIMG($log_user_id);
         $img->loadFile("/banners", "{$moveit}");
         $img->resizew(800);
         $img->saveFile("/banners", "{$moveit}", 90);
         header("location: profile.php?user={$log_uname}");
         $db = null;
         exit;
         //echo $moveit;
     } else {
         $errormsg = $upload->checkFile($regex);
         echo $errormsg[0];
     }
开发者ID:raface,项目名称:backburnr,代码行数:31,代码来源:profWrite.php

示例5: edit

 /** Fonction de modification des informations de l'utilisateur via son profil
  *
  */
 public function edit()
 {
     if (isset($_SESSION['user_id']) && isset($_SESSION['user_email'])) {
         if (isset($_POST)) {
             if (isset($_POST['first_name'])) {
                 $first_name = $_POST['first_name'];
             } else {
                 $first_name = null;
             }
             if (isset($_POST['last_name'])) {
                 $last_name = $_POST['last_name'];
             } else {
                 $last_name = null;
             }
             if (isset($_POST['email'])) {
                 if ($this->coreCheckEmail($_POST['email'])) {
                     $email = $_POST['email'];
                 } else {
                     $messageFlash = 'Wrong email adress. Please try again.';
                     $this->coreSetFlashMessage('error', $messageFlash, 4);
                     header('Location:profile/home');
                     exit;
                 }
             }
             if (isset($_POST['BirthDateSaved'])) {
                 $birth_date = $_POST['BirthDateSaved'];
             } elseif (isset($_POST['birth_day']) && isset($_POST['birth_month']) && isset($_POST['birth_year'])) {
                 $birth_date = $_POST['birth_day'] . "/" . $_POST['birth_month'] . "/" . $_POST['birth_year'];
             } else {
                 $birth_date = null;
             }
             if (isset($_POST['location'])) {
                 $location = $_POST['location'];
             } else {
                 $location = null;
             }
             if (isset($_POST['skills'])) {
                 $skills = $_POST['skills'];
             } else {
                 $skills = null;
             }
             if (isset($_POST['description'])) {
                 $description = $_POST['description'];
             } else {
                 $description = null;
             }
             if (isset($_POST['school'])) {
                 $school = $_POST['school'];
             } else {
                 $school = null;
             }
             if (isset($_POST['work'])) {
                 $work = $_POST['work'];
             } else {
                 $work = null;
             }
             $id = $_SESSION['user_id'];
             if (!empty($_FILES['userPicture']['name'])) {
                 $file = new Upload($_FILES['userPicture']['name'], $_FILES["userPicture"]["tmp_name"], 'assets/img/user_pp/', '');
                 if ($file->extControl()) {
                     if ($file->moveFile()) {
                         $userPicture = $file->setNom();
                         $lastId = $this->model->insertUserPicture($userPicture);
                     } else {
                         // fichier non déplacé
                         define("TITLE_HEAD", "An error occur.");
                         $messageFlash = 'An error occur. Please try again.';
                         $this->coreSetFlashMessage('error', $messageFlash, 3);
                         header('Location:profile/home');
                         exit;
                     }
                 } else {
                     // Extension non autorisée
                     define("TITLE_HEAD", "An error occur.");
                     $messageFlash = 'Invalid file extension. Please try again.';
                     $this->coreSetFlashMessage('error', $messageFlash, 3);
                     header('Location:profile/home');
                     exit;
                 }
             } else {
                 if (isset($_POST['userPictureSaved'])) {
                     // TODO
                     // Supprimer l'ancienne photo
                     $userPicture = $_POST['userPictureSaved'];
                     $lastId = $this->model->insertUserPicture($userPicture);
                 } else {
                     $lastId = null;
                 }
             }
             if (!$this->model->update_profile($id, $first_name, $last_name, $birth_date, $email, $location, $description, $skills, $school, $work, $lastId)) {
                 // Si pas de données updaté
                 define("TITLE_HEAD", "An error occur.");
                 $messageFlash = 'An error occur. Please try again.';
                 $this->coreSetFlashMessage('error', $messageFlash, 3);
                 header('Location:profile/home');
                 exit;
             } else {
//.........这里部分代码省略.........
开发者ID:Totoyor,项目名称:Volunteers,代码行数:101,代码来源:ProfileController.php


注:本文中的Upload::moveFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。