paklic9

Experience

210

0 Best Reply Awards

  • Member Since 4 Months Ago
  • 0 Lessons Completed
  • 0 Favorites

28th January, 2018

paklic9 left a reply on File Validation • 3 months ago

Thanks! That works.

paklic9 started a new conversation File Validation • 3 months ago

I have problem with file validation. It doesnt validate. I am not sure, if I am doing it right, because I know, there is more similarly ways to do it. Can you help me? How to validate the file.

My code:

    $files = $request->file('soubory');
    if($request->hasFile('soubory'))
    {
      $i = 0;
      $dbfilename = [];
      foreach ($files as $file) {
        $rules = array('file' => 'required|mimes:png,gif,jpeg,txt,pdf,doc');
        $validator = \Validator::make(array('file'=> $file), $rules);
        if($validator->passes()){
          $fileExtension = $file->getClientOriginalExtension();
          $fullFileName = $file->getClientOriginalName();
          $filename = pathinfo($fullFileName)['filename'];
          $file->storePubliclyAs('/upload/' . Auth::user()->id, $filename . ('_') . time() . rand(0, 99999) . $i . '.' . $fileExtension, 'public');
          array_push($dbfilename,$fullFileName);
          $i++;
        }
      }
      $dbfilename = implode(', ', $dbfilename);

Thanks in advance for help.

15th January, 2018

paklic9 left a reply on Shared Hostling - Error When Trying Insert Something To Database • 4 months ago

@Snapey

They doesnt say, that i cannot have the file. I have it on server, but it not using it for some reason. On some czech forum, they just said, that I need write all to config files.

I copied whole projekt to www folder(public) and made .htaccess (that redirect to public) and code is:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/ [L]
</IfModule>

and then in public I have main .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On

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

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

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

I had to remove this(because Options -MultiViews isnt allowed):

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

@mdecooman

Actually its just small project for my friend and he wants to have it hosted in czech (with small budget on the beginning) and he is paying it.

In near future I plan to buy some small cheapest vps (somewhere in EU) for my project, but in this situation I will need to use the shared hostling like that.

And for now I am learing/developing on localhost on windows. And I know, what is and how to use virtualbox (like a home vps).

paklic9 left a reply on Shared Hostling - Error When Trying Insert Something To Database • 4 months ago

@mdecooman

Thanks for answer. Yeah, only I have acess to the ftp, where data are stored, so it should be okey, as you say. And no my apllication is not collecting credit cards. It would be different, if the application collects credit cards?

About that chmod, i thought it. Just some guy said it on forum, that you should do it (and here its also written https://github.com/JosefKuchar/Larawed#post-installpatch ).

P.S.: I am just beginner in all of this, still learing a lot. I recently started to interest in Laravel and all these things. And I am just student on high school, so for it I am using shared hostling(it costs less than 30$ per year without domain). VPS would be like 2x more (60$). But in future I will move to VPS. It looks like everything will work now on shared hostling also.

paklic9 left a reply on Shared Hostling - Error When Trying Insert Something To Database • 4 months ago

Okey, I got it. The problem was in session.php and exactly in secure. I had it on true, when i set it to false, it is working. Does somebody know, why? I have HTTPS on website.

I just found, that I can only change APP_KEY and database information and it working all, because other stuffs will be set by default, if it cannot use .env file. So only if I need modify some settings, I have to change it, otherwise i can leave it, right? Like the default secure looks:

'secure' => env('SESSION_SECURE_COOKIE', false),

I have last two question. Snapey why is that problem? To use it without .env file? Do I break some security thing, when i am not using .env, but filling it hardcore in config files? It is safe to use it without .env in comercial use?

And do I need to set access rights 777 to storage and bootstrap/cache recursively? I found that on internet, but it looks like everything is also working without it. I am scared about setting things to 777, because it usualy break some security or am I wrong?

P.S.: All biggest shared hostlings in our country (Czech republic) do not allow to use .env file. At least, what i checked.

paklic9 left a reply on Shared Hostling - Error When Trying Insert Something To Database • 4 months ago

Okey, I got it. I thank you all for help. The problem was in session.php and exactly in cookie. I had it like this (because one little older tutorial said it):

'cookie' => 'laravel_session'

But i should be:

'cookie' => str_slug('laravel', '_').'_session',

I just found, that I can only change APP_KEY and database information and it working all, because other stuffs will be set by default, if it cannot use .env file. So only if I need modify some settings, I have to change it, otherwise i can leave it, right? Like the default cookie looks:

'cookie' => env(
'SESSION_COOKIE',
str_slug(env('APP_NAME', 'laravel'), '_').'_session'
),

I have last two question. Snapey why is that problem? To use it without .env file? Do I break some security thing, when i am not using .env, but filling it hardcore in config files? It is safe to use it without .env in comercial use?

And do I need to set access rights 777 to storage and bootstrap/cache recursively? I found that on internet, but it looks like everything is also working without it. I am scared about setting things to 777, because it usualy break some security or am I wrong?

P.S.: All biggest shared hostlings in our country (Czech republic) do not allow to use .env file. At least, what i checked.

paklic9 left a reply on Shared Hostling - Error When Trying Insert Something To Database • 4 months ago

jlrdw: I should have done these basics.

Snapey: I cannot use env file on this shared hostling, so I had to set all settings inside config files and I did set all setting like in .env file or default, if it wasnt in .env. And SESSION_DOMAIN wasnt in .env, so I left it on default (null). So it looks like this:

'domain' => null,

I tried to change it to:

'domain' => '.kingworld.cz',

But its not working and I am not sure, if its right set.

So what to do? Is it possible to change some parametrs in config to make it work?

14th January, 2018

paklic9 started a new conversation Shared Hostling - Error When Trying Insert Something To Database • 4 months ago

Hi, I have problem with setting correctly my website on shared hosting (forpsi). I did all what I found on internet. And all is working except one thing. The problem is, when I am trying to write/insert something to databse (login, register, insert a form). It always do: The page has expired due to inactivity. Please refresh and try again.

I also tried to set access rights 777 to storage and bootstrap/cache recursively, but it didnt helped. PS: Reading and getting data from database is working and showing the data from database on page is also working.

13th January, 2018

paklic9 left a reply on Undefined Variable In Function With Query • 4 months ago

oh, that's easy. I was trying to do it much harder. :D Thank you so much.

paklic9 started a new conversation Undefined Variable In Function With Query • 4 months ago

Hi, I have problem with my function, error is: "Undefined variable: filtry". I know why, the variable $filtry have to be defined in query function (like variable $j is), then it is working. But I cannot have this variable static, because variable $filtry will be always diffrent, so I need set it before function, then call it in function. Is it possible? Thanks in advance for help.

My function:

function dbselect($tabulka, $filtry){ $inzerce = \DB::table($tabulka) ->where(function($query){ $j = 0; foreach ($filtry as $filtr) { $filtr = \Request::has($filtr) ? \Request::get($filtr) : []; if(isset($filtr)){ $i = 0; foreach ($filtr as $polozka) { if ($i == 0) { $query->where($filtry[$j],'=', $polozka); $i++; } else{ $query->orwhere($filtry[$j],'=', $polozka); $i++; } } } $j++; } })->get(); }

Calling function:

$filtry = ['kategorie']; dbselect('zviratas', $filtry);

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.