wbf

wbf

Member Since 2 Months Ago

Experience Points 250
Experience Level 1

4,750 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected]s.com with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

21 May
1 month ago

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

Hello all,

I'd like to inform you that a2hosting has solved the problem of video upload. here is their answer:

"Our engineers have been able to pin down the most likely cause of the uploading issue. It is related to the CloudLinux configuration and Apache timeout configuration."

30 Apr
1 month ago

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

@SIANGBOON - Sorry but that's all what I knew so far because the a2hosting are still figuring out what caused the problem. Anyway, I will forward the email I got from a2hosting about this topic:

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Hello Walid,

Thank you for the MTR results. While we were investigating we found a server issue that causes errors when uploading files larger than 2-3MB. This issue is affecting all of our shared hosting servers, and our engineering team is working with our software vendors to find the root cause and get uploads working properly again. We appreciate your patience, and we'll keep you updated on this issue.

Thank you, """""""""""""""""""""""""""""""""""""""""""""""""""""""""""

In an earlier email they asked from me to do a MTR test and I provided them with the results, then I got the mentioned email.

I will let you informed by the results I get from them.

Thanks and regards

28 Apr
1 month ago

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

Hello folks... Well, thank you all for your help and your time trying to help me solve the problem. We've all been right, the problem is in the server, and a2hosting is working now to fix it. Thanks and wish you all the best guys.

25 Apr
1 month ago

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

@SIANGBOON - You were actually right :D. I've contacted the support and they are working to disable the mod_security. Let's see if this can happen. Anyway, what do you think about trying to upload the post using ajax? would that help in solving anything? I think it won't since the normal upload method doesn't work...

24 Apr
2 months ago

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

@JLRDW - Thanks for joining. My host is a2hosting.

About the files upload and the directories that you have mentioned, I'm not having any problem uploading any kind of files that are under a certain size (1.1MB), but when they are bigger the error starts showing. I'm not having this problem on localhost, so that's why it should be something to do with the hosting server configuration. I checked the server's configuration and contacted the support team, but everything is all right there... they actually told me that they give permission to apply your configuration through htaccess. this is how my htaccess looks like:

RewriteEngine On
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

php_value session.gc_maxlifetime 10800
php_value max_input_time 10800
php_value max_execution_time 10800
php_value upload_max_filesize 64M
php_value post_max_size 60M
php_value memory_limit 64M


<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    Options +FollowSymLinks
    Options -Indexes 

    
    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ / [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    
</IfModule>

But the weird thing is when I change the post_max_size to 1M, the 1.1MB files are still being uploaded!

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

@SIANGBOON - well exactly... that's what I saw when I was searching how to disable the Mod_security, but there is no such thing on my cpanel... I'm on a2hosting

23 Apr
2 months ago

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

No, nothing... I'm still getting the same page. do you think it is something related to my configuration? or it is something that the hosting server should take care of?

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

Good news.. after disabling the https finally, I'm getting this error:

This site can’t be reached
The connection was reset.

Try:
Checking the connection
Checking the proxy and the firewall
Running Windows Network Diagnostics
ERR_CONNECTION_RESET
Check your internet connection.
Check any cables and reboot any routers, modems, or other network devices you may be using.

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

@SIANGBOON - Hello and thanks for joining. I've contacted the support team and trying to disable the mod_security

22 Apr
2 months ago

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

Sorry, it's my bad... updated now: user_ini.cache_ttl = 300 not upload_max_filesize=300...

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

Hmm... I think it's about timing? maybe? well, I tried to upload a file of 1.10 MB, and it failed... then, I removed the loading script, and tried to upload the same file again, and it worked. then, I switched to upload a bigger file and it failed.

I have the following:

max_input_time = -1

max_input_vars = 1000

max_input_vars = 128M

output_buffering = 4096

post_max_size = 64M

realpath_cache_size = 4096K

realpath_cache_ttl = 112

upload_max_filesize = 256M

upload_max_filesize = 300

memory_limit = 128M

max_input_nesting_level = 64

max_file_uploads = 50

max_execution_time = 300

Sorry to mention all these, but frankly speaking I don't know the role of each of them and if they may affect the results.. as far as I know, I think the values are okay, right?

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

@SNAPEY - I meant by "they said that they have no such rule" is that they don't have restrictions to the uploaded files size from their side... It's up to the user to modify the php values. the post_max_size from the phpinfo() showed 64M, which is the same value I chose. and I've also added these lines to the .htaccess file: php_value session.gc_maxlifetime 10800 php_value max_input_time 10800 php_value max_execution_time 10800 php_value upload_max_filesize 64M php_value post_max_size 64M

as mentioned on stackoverflow 's link you shared.

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

@SNAPEY - Just to make sure that everything is right with forms, I've created a testing page with no scripts, no forms, nothing except the posting area, and I'm still having the same problem. I would really thank you again for your help. I really appreciate it

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

@SNAPEY - You're absolutely right! I've tried actually the dd($request) at the beginning of the store function, but it didn't work; it just took me to the same error page with the URL /post/id/store... the weird thing is when the file is smaller than 1MB, it uploads normally then return to /profile/id. while on the localhost, no matter how big the file is (I mean smaller than the max_size), it works normally. I think I'll try to re-upload the whole thing from the beginning and see what happens then...

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

@MAVERICKCHAN - Oh, I'm sorry... yes I was using a PUT, then I changed it to POST just before posting it here because someone told me that the method POST should be used when dealing with files upload... Actually neither POST nor PUT worked online, but both of them worked on localhost.

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

@TISUCHI - Sorry if I didn't get you right, but is it something other than

$this->validate($request,[ 'body' => 'required', 'postpic' => 'nullable|max:40000' ]);

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

@SNAPEY - Well, after checking the phpinfo, I found that everything is all right there with the sizes :s that's really weird...

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

@SNAPEY - thanks Snapey for replying, but the file I'm trying to upload is way smaller than the post_max_size and the upload_max_filesize... I think I'll try doing what you suggested by creating a route than returns the phpinfo and see what's there, then I'll come and tell you what I found :) thanks a lot for your help guys, I really appreciate it

wbf left a reply on MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

@TISUCHI - Hello and thank you for the fast reply :) actually the memory limit is 768MB

wbf started a new conversation MethodNotAllowedHttpException With Laravel5.4 When Uploading Files Bigger Than 1MB Online, But It Works Perfectly On Localhost

I'm using Laravel 5.4 for my website, and I'm getting a problem when the user tries to upload files bigger than 1MB. This problem doesn't appear on localhost. The error I get is nothing related to the file size, but it's a MethodNotAllowedHttpException in RouteCollection.php line 251. The method I'm using to upload the files is 'PUT'.

I've tried the " $request->file('postpic')->storeAs('/public/post_pic/',$filenametostore);" and the "Storage::putFileAs('public/post_pic', $request->file('postpic'), $filenametostore);" but none of them worked online for files bigger than 1MB. I also checked the php options on cpanel, and they are set to accept files size of 50MB (max_file_size), a memory_limit of 768MB, a post_max_size of 128MB. I also contacted the hosting server, and after opening a ticket to see what's wrong, I've got an answer that there is a programming bug and the server's configuration is fine. I've spent two days looking for an online solution, but I didn't get any good results about this topic, that's why I'm asking this question here, and I would really appreciate any support to solve it. Finally, I've noticed that when I upload the same 9MB file offline Vs online: looking at the Network tab in the browser, I could find that there were updates about the user's ID and the file Id when uploading this file offline, but online, the network freezes for a while without showing any updates, then the error page appears. When using a smaller file (less than 1.2MB) everything works normally online and offline.

My route is:

Route::PUT('/post/{id}/store',[
    'as' => 'storepost',
    'uses' => '[email protected]'
]);

My controller function is:

public function store(Request $request, $id, loggeduser $lu)
    {
        $this->validate($request,[
            'body'=>'required',
            'postpic'=>'nullable|max:40000'
        ]);
        
        $profile=profile::find($id);
        $isvideo=0;
            
        if($request->hasfile('postpic')){

            $filenamewithext=$request->file('postpic')->getClientOriginalName();
            $filename=pathinfo($filenamewithext,PATHINFO_FILENAME);
            $extension=$request->file('postpic')->getClientOriginalExtension();
            $filenametostore='1_'.$filename.'_'.time().'.'.$extension;
            $orgimage = Storage::disk('local')->putFileAs('public/post_pic', $request->file('postpic'), $filenametostore);
                
            if(substr($request->file('postpic')->getMimeType(), 0, 5) == 'image') {
                //Resize image here
                    
                $imagepath = public_path('storage/post_pic/'.$filenametostore);
                $img = Image::make($imagepath)->resize(700, 400, function($constraint) {
                    $constraint->aspectRatio();
                });
                $img->save($imagepath);
                    
            }elseif(substr($request->file('postpic')->getMimeType(), 0, 5) == 'video') {
                //it's a video                    
                $isvideo=1;
            }
        }else{
            //there is no photo
            $filenametostore='0';
        }
            
        $logged_user_id=$lu->userid;
        $post=new post();
        $post->post_pic=$filenametostore;
        $post->isvideo = $isvideo;
        $post->body=$request->input('body');
        $post->user_id=$logged_user_id;
        $post->profile_id=$id;
        $post->save();

        return redirect('/profile/'.$id)->with('success','Your story is alive..');
        

    }

The blade file:

{!!Form::open(['action'=>['[email protected]','id'=>$profile->id],'method'=>'PUT','enctype'=>'multipart/form-data','files'=>true])!!}

{!! csrf_field() !!}

<input id="postpic" type="file" name="postpic" class="btn btn-primary" style="width:100%;"/>

{{Form::textarea('body','',['class'=>'form-control','required','placeholder'=>'Post a story on your profile..'])}}

{{Form::submit('Post',['class'=>'btn btn-success'])}}

{!!Form::close()!!}

Thank you in advance.