Uploaded file not available for processing?

Problem:

When I choose the file and submit the form, it goes to the processing page, but apparently doesn't send the file array, just the name of the file.

Goal:

Accept and upload file to appropriate directory.


Environment:

  • Local
  • OSX / MAMP Pro
  • PHP / Laravel 4

Upload Controller:

public function uploadLogo() {
    $locals['route'] = route('saveProfileLogo');
    return View::make('upload_file', $locals);
}

Upload View:

<form method="get" action="{{{$route}}}" enctype="multipart/form-data" class="grid-form">
    <label>File</label>
    <input type="file" name="fresh_file" />

    <input type="submit" class="btn btn-primary" value="Start Upload" />
</form>

Save Controller:

public function saveLogo() {
    // Always fails
    // if (!Input::hasFile('fresh_file'))
        // return 'No file provided.';

    // Always shows: array(1) { ["fresh_file"]=> string(21) "Angular Mountains.jpg" }
    // dd(Input::all());

    Input::file('fresh_file')->move(public_path() . '/files');
    return View::make('upload_file_response');
}

Answers


You should use the method="post" in the form, not get, that's why you see the file as a string.


Need Your Help

How to disable bootstap nav-justified collapse for smaller devices

twitter-bootstrap tabs collapse nav justify

I am using bootstrap to justify a bunch of tabs to evenly fit the width of the parent element.

Python: large projects and making changes to files used everywhere

python eclipse pydev

Suppose I had a large project in Java, and a class, UsedEverywhere, which was used everywhere. If I changed the return type of the returnsSomething method of that class, my IDE would tell me about