本文整理汇总了PHP中File::move方法的典型用法代码示例。如果您正苦于以下问题:PHP File::move方法的具体用法?PHP File::move怎么用?PHP File::move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File::move方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadFileToStorage
public static function uploadFileToStorage(File $file)
{
$filename = 'file_' . substr(md5(uniqid(rand())), 6) . '_' . $file->getClientOriginalName();
$path = self::uploadPath();
$file->move($path, $filename);
return $path . DIRECTORY_SEPARATOR . $filename;
}
示例2: upload
/**
* Handle all files
* @return void
*/
public function upload()
{
foreach ($this->files as $source => $dest) {
$file = new File($source);
$file->move($dest['path'], $dest['filename']);
}
}
示例3: saveProduct
public function saveProduct()
{
$data = Input::all();
if (!Auth::guest()) {
$validator = Validator::make($data, Product::$rules);
if ($validator->passes()) {
$user = Auth::user();
$product = new Product();
$product->user_id = $user->id;
$product->product_name = $data['product_name'];
$product->description = $data['description'];
$product->start_price = $data['start_price'];
$product->save();
if (isset($data['categories']) && !empty($data['categories'])) {
$product->categories()->attach($data['categories']);
}
if (Session::has('files')) {
$files = Session::get('files');
// get session files
foreach ($files as $key => $file) {
$directory_file = public_path() . '/product_images/' . $file;
if (File::exists($directory_file)) {
File::move($directory_file, public_path() . '/product_images/product_' . $product->id . '_' . $key . '.jpg');
}
}
Session::forget('files');
}
return Response::json(array('success' => true, 'product' => $product));
}
return Response::json(array('success' => false, 'type' => 'form_error', 'errors' => $validator->messages()));
}
return Response::json(array('success' => false, 'type' => 'log_error', 'error' => 'In order to save your product, please, log in!'));
}
示例4: update
public function update()
{
$rules = array('name' => 'required', 'desc' => 'required', 'totalposts' => 'required|numeric');
$validator = Validator::make(Input::all(), $rules);
$badgeid = Input::get('id');
if ($validator->fails()) {
return Redirect::to('admin/editbadge/' . $badgeid)->withErrors($validator)->withInput();
} else {
$name = Input::get('name');
if (Input::get('badge')) {
$image = explode('/', Input::get('badge'));
$image = urldecode(end($image));
$extension = explode(".", $image);
$extension = end($extension);
$img = Image::make('files/' . $image);
$img->resize(160, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->save('files/' . $image);
$newname = date('YmdHis') . '_' . Str::slug($name, '_') . '.' . $extension;
File::move('files/' . $image, 'badges/' . $newname);
}
$badge = Badge::find($badgeid);
$badge->name = Input::get('name');
$badge->description = Input::get('desc');
if (Input::get('badge')) {
$badge->image = $newname;
}
$badge->total_posts = Input::get('totalposts');
$badge->save();
Session::flash('success', 'Badge updated');
return Redirect::to('admin/badges');
}
}
示例5: move
/**
* Move or rename a file
*
* @param string $from The full path of the file to move
* @param string $to The full path of the target file
*
* @return boolean True on success
*/
public function move($from, $to)
{
$ret = $this->fileAdapter->move($from, $to);
if (!$ret && is_object($this->abstractionAdapter)) {
return $this->abstractionAdapter->move($from, $to);
}
return $ret;
}
示例6: moveResource
/**
* Move the resource to the course folder.
*
* @param Course $post
* @param $path
*/
public function moveResource(Course $post, $path)
{
$old_path = public_path('uploads' . DIRECTORY_SEPARATOR . $path);
$new_path = public_path('uploads' . DIRECTORY_SEPARATOR . $post->slug);
\File::makeDirectory($new_path, $mode = 0777, true, true);
$new_path .= DIRECTORY_SEPARATOR . $path;
\File::move($old_path, $new_path);
}
示例7: whenAccountWasInstalled
public function whenAccountWasInstalled(AccountWasInstalled $account)
{
$langPath = app_path('lang');
$enPath = "{$langPath}/en";
$enGbPath = "{$langPath}/en_GB";
if (File::exists($enPath)) {
File::move($enPath, $enGbPath);
}
}
示例8: move
public function move($destination)
{
$destination = dirname($destination) . '/' . basename($this->source);
if (File::move($this->source, $destination)) {
$this->source = $destination;
return true;
} else {
return false;
}
}
示例9: upload
/**
* @ORM\PostPersist()
* @ORM\PostUpdate()
*/
public function upload()
{
if (null === $this->file) {
return;
}
// s'il y a une erreur lors du déplacement du fichier, une exception
// va automatiquement être lancée par la méthode move(). Cela va empêcher
// proprement l'entité d'être persistée dans la base de données si
// erreur il y a
$this->file->move($this->getUploadRootDir(), $this->src);
unset($this->file);
}
示例10: upload
/**
* @ORM\PostPersist()
* @ORM\PostUpdate()
*/
public function upload()
{
if (null === $this->file) {
return;
}
// s'il y a une erreur lors du déplacement du fichier, une exception
// va automatiquement être lancée par la méthode move(). Cela va empêcher
// proprement l'entité d'être persistée dans la base de données si
// erreur il y a
$this->file->move($this->getUploadRootDir(), $this->path);
unset($this->file);
}
示例11: update
/**
* Update the specified resource in storage.
*
* @param PhotosRequest $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(PhotosRequest $request, $id)
{
$photo = Photos::findOrFail($id);
$old_slug = $photo->slug;
$input = \Input::all();
$input['slug'] = '/img/photos/' . $photo->id . '/' . \trslug::trslug(\Input::get('title') . '.jpg');
$photo->update($input);
\File::move(storage_path('app') . $old_slug, storage_path('app') . $photo->slug);
//
Photos::findOrFail($id)->update(\Input::all());
return \Redirect::back()->with('message', 'Kaydedildi!');
}
示例12: upload
/**
*
* @ORM\PostPersist()
* @ORM\PostUpdate()
*
*/
public function upload()
{
if (null === $this->file) {
return;
}
//Si ancien fichier on supprime
if (null !== $this->tempFileName) {
$oldFile = $this->getUploadRootDir() . '/' . $this->id . '.' . $this->tempFileName;
if (file_exists($oldFile)) {
unlink($oldFile);
}
}
//On deplace
$this->file->move($this->getUploadRootDir(), $this->id . '.' . $this->url);
// chmod($this->getUploadRootDir().'/'.$this->id.'.'.$this->url,644);
}
示例13: upload
/**
* Called after entity persistence
*
* @ORM\PostPersist()
* @ORM\PostUpdate()
*/
public function upload()
{
// The file property can be empty if the field is not required
if (null === $this->file) {
return;
}
// Use the original file name here but you should
// sanitize it at least to avoid any security issues
// move takes the target directory and then the
// target filename to move to
$this->file->move($this->getUploadRootDir(), $this->path);
// Set the path property to the filename where you've saved the file
//$this->path = $this->file->getClientOriginalName();
// Clean up the file property as you won't need it anymore
$this->file = null;
}
示例14: importProcess
function importProcess()
{
$resultData = File::uploadMultiple('theFile', 'uploads/tmp/');
$total = count($resultData);
for ($i = 0; $i < $total; $i++) {
$targetPath = '';
$theFile = $resultData[$i];
$sourcePath = ROOT_PATH . $theFile;
$shortPath = 'contents/plugins/' . basename($theFile);
$targetPath .= $shortPath;
File::move($sourcePath, $targetPath);
$sourcePath = dirname($sourcePath);
rmdir($sourcePath);
File::unzipModule($targetPath, 'yes');
$installFile = ROOT_PATH . $shortPath . '/install/update.sql';
if (file_exists($installFile)) {
Database::import($installFile);
}
}
}
示例15: update
public function update()
{
$id = Input::get('id');
$rules = array('image_banner' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('admin/editbanner/' . $id)->withErrors($validator)->withInput();
} else {
$image = explode(url() . '/', Input::get('image_banner'));
$realpath = public_path($image[1]);
$newname = date('YmdHis') . '.jpg';
File::move($realpath, 'images/slider/' . $newname);
// update db
$banner = Banner::find($id);
$banner->image = 'images/slider/' . $newname;
$banner->save();
Session::flash('success', 'Banner updated');
return Redirect::to('admin/banners');
}
}