0

I have this in view.blade.php

{!!Form::open(['url'=>'/Path/somepath','method'=>'POST','files'=>true])!!}
<div>
    <span>{!!Form::label('Photo','Your photo')!!}</span>
     <span>{!! Form::file('Photo')!!}</span>
</div>
{!!Form::close()!!}

I have this in the controller method:

    $destinationPath = 'Folder/Subfolder1/Subfolder2'; 
    $extension = Input::file('Photo')->getClientOriginalExtension(); 
    $size = Input::file('Photo')->getSize();
    $mime = Input::file('Photo')->getMimeType();
    $path = Input::file('Photo')->getRealPath();
    $fileName=’ 3da0d12d6d8667963392a446262b1773JJ.jpg’;
    $ufile=Input::file('Photo');
    $ufile->move($destinationPath, $fileName);
    $details=[$size,$mime,$path,$fileName,$ufile];
    dd($details);

and the result is this:

array:5 [▼
  0 => 7673
  1 => "image/jpeg"
  2 => "C:\wamp2\tmp\php984F.tmp"
  3 => "3da0d12d6d8667963392a446262b1773JJ.jpg"
  4 => UploadedFile {#29 ▼
    -test: false
    -originalName: "vali.jpg"
    -mimeType: "image/jpeg"
    -size: 7673
    -error: 0
  }
]

But when I look into C:\wamp2\tmp\ the file php984F.tmp is not there. My problem was that moving the file to another path was not working… it can’t be working since the uploading seems not to work in the first place. So, what am I doing wrong ?

3
  • The result looks fine, check that there is valid directory Folder/Subfolder1/Subfolder2 and has 777 permission Commented Jul 22, 2015 at 17:14
  • How do I check that ? And why there is no file in C:\wamp2\tmp ? Commented Jul 22, 2015 at 17:34
  • it's a temporary file, it will be deleted after transfer Commented Jul 22, 2015 at 17:52

1 Answer 1

1

correct the destination directory path

 $destinationPath = base_path() . '/Folder/Subfolder1/Subfolder2'; // replace with your required destination directory
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.