Support the ongoing development of Laravel.io →
Input Forms
Last updated 2 years ago.
0

Here is something simpler still can't get it to work. in HTML 5 ajax uploader

 public function upfle(){

    $file = Input::file('files');
    $destinationPath = '/public/uploads/';
    $ext      = $file->guessClientExtension();  // Get real extension according to mime type
    $fullname = $file->getClientOriginalName(); // Client file name, including the extension of the client
    $hashname = date('H.i.s').'-'.md5($fullname).'.'.$ext; // Hash processed file name, including the real extension
    $upload_success = Input::file('files')->move($destinationPath, $hashname);

}
Last updated 2 years ago.
0

The code is working now

        /*Upload Images */
public function upload_file(){

    $file = Input::file('files');

    $allowed_ext = array('jpg','jpeg','png','gif');
    $ext= $file->guessClientExtension();  // Get real extension according to mime type

    $fullname = $file->getClientOriginalName(); // Client file name, including the extension of the client
    $hashname =substr_replace(sha1(microtime(true)), '', 12).'.'.$ext;

    $destinationPath = 'assets/uploads/';

    if(!in_array($ext,$allowed_ext)){
        echo json_encode(array('status'=>'Invalid File Extension'));
    }
    else{
        $upload_success = Input::file('files')->move($destinationPath, $hashname);
    }

}
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

kyoukhana kyoukhana Joined 28 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.