I have a form in my HTML, in the action, I would like to set the page where I want to send the data:
<form action="wherever.com" method="post" target="_blank" style="display: inline;">
The problem is Laravel, in my .env file I set this:
WHEREVER_FORM="http://wherever.com"
Ok, now I want to set this env variable in my ACTION, I have tried with this:
action="env('WHEREVER_FORM')"
Also this:
action="env(WHEREVER_FORM)"
And this:
action="{{env('WHEREVER_FORM')}}"
I know that I can do this from a env variable, but I donĀ“t find how to do it, in the Laravel Documentation I found this:
$env = env('APP_ENV');
// Return a default value if the variable doesn't exist...
$env = env('APP_ENV', 'production');
This is not enough to me.
Someone can help me?
I think your .env file setup is ok:
WHEREVER_FORM="http://wherever.com"
And also:
<form action="{{env('WHEREVER_FORM')}}" method="post" target="_blank" style="display: inline;">
However, Please make sure that you reboot your application after changing .env file. You can do this by:
php artisan serve
Related
Thank you in advance,
I have one route defined like
Route::get('/registration/verify/{token}', 'UserController#verifyRegisteredEmail')->name('registration.email.verification');
I am accessing the route like
route('registration.email.verification', ['token' => $email_register_verification_token]);
when I am printing above line it is giving them out as below
http://localhost/registration/verify/87006dcc95bcf7a9ea83e523f2aa53f9
But it should be
http://localhost/{root}/registration/verify/87006dcc95bcf7a9ea83e523f2aa53f9
Try setting the proper APP_URL in .env. It only outputs the wrong value from there.
Try to set the APP_URL inside .env file, and run this command php artisan config:cache
If you have some routes with a same prefix, You can use prefix option in routes groups like this:
Route::prefix('Your Root')->group(function(){
Route::get('/registration/verify/{token}', 'UserController#verifyRegisteredEmail')->name('registration.email.verification');
});
I want to write <scrip></script> for API address form but I don't know where to write .
I created file a script.php in resources/views/script.php then I call
<script src= "{{ asset('resources/views/script.php') }}" >in app.blade.php but didn't work
Change your script.php name to script.blade.php then you can import it using #include('script');
Change resources/views/script.php to resources/views/script.blade.php
Then you can use the blade template engine :
#include('script');
I'm using Laravel 5 with Blade templates. My templates look like so:
drone.blade.php
#include('drone.gallery')
drone/gallery.php
{{ url('images-gallery/DSC_0072.JPG') }}
However, the url() function does not work inside my include file. If I copy the {{ url('images-gallery/DSC_0072.JPG') }} line into drone.blade.php it works as expected.
Why is the url() parameter not working inside include?
Thanks in advance.
I can see your filename is gallery.php.
Can you plaese change it to gallery.blade.php
I'm writing a Artisan command to do batch image uploads to the application.
Trying to look for the equivalent command to do the following
$file = Input::file('photo');
Becaues I'm in the command line the Input class doesn't work.
I tried File::get('/path/to/file') but it didn't return the same object.
Input::file() will only receive files via form POST:
<form method="POST" enctype='multipart/form-data' action="index.php">
<input type=file name=upload>
<input type=submit name=press value="OK">
</form>
What means that you cannot use Input::file() unless you are doing something like this to test your upload
curl --form upload=/path/to/file http://your/site/url/upload
If you are trying to send files via command, like
php artisan upload /path/to/file
You'll need to get this filename, read the file from disk and do whatever you need to do with it.
I was trying to set up a basic log in form with a following code:
<?=form_open(base_url() . 'main/login'); ?>
However after submitting the form the url shows this:
example.com/main/http//example.com/http//example.com/main/login
So I guess in essence for some reason the base-url is printed twice before the controller/method declaration. If I clear the base url value in my config file then the application works normally. I am however curious on what could cause this. For additional information I am working on xampp with a virtualhost and I have mod-rewrite on with a .htaccess file located at the document root.
CodeIgniter automatically adds the base_url to the action of the form when you use the form helper.
For example, you can use:
<?=form_open('main/login'); ?>
which will produce:
http//example.com/main/login
And a correct URL! Pretty simple! :D
More information at:
http://codeigniter.com/user_guide/helpers/form_helper.html
The file config.php under application/config has the setting:
$config['base_url'] = '';
Give it the folder/directory path. For example:
$config['base_url'] = 'http://localhost/ci_test/';
Don't forget to mention the protocol (http://). Alternatively try the site_url() method instead of base_url() for form opening. Skip it if using the form_open() function:
<form action="<?php echo site_url('main/login'); ?>"> ... </form>
Or
<?php form_open('main/login'); ?>
For more help: http://codeigniter.com/user_guide/helpers/url_helper.html
Not sure about the .htaccess file you have used. But this might be the answer codeigniter: why is that when i echo base_url() in an href attribute of an anchor tag, it echoes twice
Try it by parameter:
<?=form_open(base_url('main/login')); ?>
or
<?=form_open site_url('main/login')); ?>
In order to append the prefix also
You can Use
<?php echo form_open(base_url(main/login)); ?>
You have to use "echo" rather than because it not works in some browsers....