Can't get input values with enctype=“multipart/form-data”











up vote
0
down vote

favorite












I'm working with Forms on Laravel, and I'm still learning. I thought I had it all figured out already, but I've been alted by an issue:



When I have enctype="multipart/form-data", I can't get the input values. The file I upload still gets uploaded to the disk, but the rest of the values are not printed. If I remove enctype="multipart/form-data", I do get the values.



Form:



<form id="forms" method="POST" action="alteracaocomissao" enctype="multipart/form-data">

{{ csrf_field() }}

<div class="form-row">
<div class="form-group col-md-6">
<label for="nomeentidade">Nome:</label>
<input type="text" class="form-control" id="nome1" name="nome1" placeholder="Nome entidade" required>

</div>
<div class="form-group col-md-6">
<label for="numentidade">Nº:</label>
<input type="text" class="form-control" id="num1" name="num1" placeholder="Número" required>
</div>
</div>

<div class="form-row">
<div class="form-group col-md-6 mb-3">
<label for="conta">Conta:</label>
<input type="text" class="form-control" id="conta" name="conta" placeholder="Conta" required>
</div>

<div class="form-group col-md-3 mb-3">
<label for="balcao">Local:</label>
<select class="form-control" id="local1" name="local1" required>
<option value="">Escolher...</option>
<option value="1">Local</option>
<option value="2">Local1</option>
</select>
</div>

<div class="form-group col-md-3 mb-3">
<label for="atleracao">Tipo de alteração:</label>
<select class="form-control" id="alteracao" name="alteracao" required>
<option value="">Escolher...</option>
<option value="1">Alterar1</option>
<option value="2">Alterar2</option>
</select>
</div>
</div>

<hr>

<div class="form-row" id="buildyourform">
<div class="form-group col-md-4">
<label for="comissao">TEST:</label>
<select class="form-control" id="TEST1" name="TEST1" required>
<option value="">Escolher...</option>
<option value="1">TEST</option>
<option value="2">TEST1</option>
</select>
</div>

<div class="form-group col-md-2">
<label for="desconto">Desconto solicitado:</label>
<div class="input-group">
<input type="text" class="form-control" id="desconto" name="desconto" placeholder="Número" required>
<span class=input-group-addon>%</span>
</div>
</div>

<div class="form-group col-md-2">
<label for="add"> &nbsp </label>
<input type="button" value="Adicionar campos" class="form-control btn btn-light" id="add" />
</div>

<div class="form-group col-md-1" id="2field">
<label for="remove"> &nbsp </label>
<input type="button" value="Remover" class="form-control btn btn-light" id="remove" />
</div>

<div class="form-group col-md-2">
</div>
</div>

<hr>

<div class="form-row">

<div class="form-group col-md-12">
<label for="fundamentacao">Fundamentação:</label>
<textarea type="text" class="form-control" id="fundamentacao" name="fundamentacao" placeholder="Fundamentação do pedido" required></textarea>
</div>

</div>

<div class="form-row">
<div class="form-group col-md-2">
<label for="file2">Anexo:</label>
<input type="file" name="file2" id="file2" required>

</div>
</div>

<hr>

<button type="submit" class="btn btn-primary">Enviar</button>
</form>


Controller:



namespace AppHttpControllers;

use IlluminateHttpRequest;

class PostController extends Controller
{

public function AltComiss(Request $request)
{
session_start();

$array1 = $request -> all();
$path = $request->file('file2')->store('altComiss');

$arrayRm1 = array_shift($array1);

$_SESSION["testPostSection1"] = $array1;

return redirect('alteracaocomissao');

}
}


Route:



Route::post('alteracaocomissao', 'PostController@AltComiss');


Testing code:



@php

session_start();

if (isset($_SESSION["testPostSection1"])) {

echo '<pre>'; print_r($_SESSION["testPostSection1"]); echo '</pre>';

}

@endphp


I do have SESSION there to test if the values are getting saved, because I still havn't set up the database, and until I do I'm using SESSION to test. Obviously once I set the database up I will switch from SESSION to inserting the values into the database.



Thanks in advance!










share|improve this question






















  • I think if you try application/x-www-form-urlencoded instead for your enctype, it might work. i vaguely recall reading about this a while ago.
    – noid
    Nov 8 at 10:56






  • 1




    @noid — That's the default, so is what they were using when they removed the enctype attribute. The form includes an input with type=file. That is incompatible with application/x-www-form-urlencoded
    – Quentin
    Nov 8 at 11:03












  • Yes, as mentioned, I did use the default and I was getting the data saved and shown in the SESSION. But doing that, I do not get the uploaded file. While if I change to multipart, I do get the file but I don't get the SESSION data.
    – JohnyJohnson
    Nov 8 at 11:10















up vote
0
down vote

favorite












I'm working with Forms on Laravel, and I'm still learning. I thought I had it all figured out already, but I've been alted by an issue:



When I have enctype="multipart/form-data", I can't get the input values. The file I upload still gets uploaded to the disk, but the rest of the values are not printed. If I remove enctype="multipart/form-data", I do get the values.



Form:



<form id="forms" method="POST" action="alteracaocomissao" enctype="multipart/form-data">

{{ csrf_field() }}

<div class="form-row">
<div class="form-group col-md-6">
<label for="nomeentidade">Nome:</label>
<input type="text" class="form-control" id="nome1" name="nome1" placeholder="Nome entidade" required>

</div>
<div class="form-group col-md-6">
<label for="numentidade">Nº:</label>
<input type="text" class="form-control" id="num1" name="num1" placeholder="Número" required>
</div>
</div>

<div class="form-row">
<div class="form-group col-md-6 mb-3">
<label for="conta">Conta:</label>
<input type="text" class="form-control" id="conta" name="conta" placeholder="Conta" required>
</div>

<div class="form-group col-md-3 mb-3">
<label for="balcao">Local:</label>
<select class="form-control" id="local1" name="local1" required>
<option value="">Escolher...</option>
<option value="1">Local</option>
<option value="2">Local1</option>
</select>
</div>

<div class="form-group col-md-3 mb-3">
<label for="atleracao">Tipo de alteração:</label>
<select class="form-control" id="alteracao" name="alteracao" required>
<option value="">Escolher...</option>
<option value="1">Alterar1</option>
<option value="2">Alterar2</option>
</select>
</div>
</div>

<hr>

<div class="form-row" id="buildyourform">
<div class="form-group col-md-4">
<label for="comissao">TEST:</label>
<select class="form-control" id="TEST1" name="TEST1" required>
<option value="">Escolher...</option>
<option value="1">TEST</option>
<option value="2">TEST1</option>
</select>
</div>

<div class="form-group col-md-2">
<label for="desconto">Desconto solicitado:</label>
<div class="input-group">
<input type="text" class="form-control" id="desconto" name="desconto" placeholder="Número" required>
<span class=input-group-addon>%</span>
</div>
</div>

<div class="form-group col-md-2">
<label for="add"> &nbsp </label>
<input type="button" value="Adicionar campos" class="form-control btn btn-light" id="add" />
</div>

<div class="form-group col-md-1" id="2field">
<label for="remove"> &nbsp </label>
<input type="button" value="Remover" class="form-control btn btn-light" id="remove" />
</div>

<div class="form-group col-md-2">
</div>
</div>

<hr>

<div class="form-row">

<div class="form-group col-md-12">
<label for="fundamentacao">Fundamentação:</label>
<textarea type="text" class="form-control" id="fundamentacao" name="fundamentacao" placeholder="Fundamentação do pedido" required></textarea>
</div>

</div>

<div class="form-row">
<div class="form-group col-md-2">
<label for="file2">Anexo:</label>
<input type="file" name="file2" id="file2" required>

</div>
</div>

<hr>

<button type="submit" class="btn btn-primary">Enviar</button>
</form>


Controller:



namespace AppHttpControllers;

use IlluminateHttpRequest;

class PostController extends Controller
{

public function AltComiss(Request $request)
{
session_start();

$array1 = $request -> all();
$path = $request->file('file2')->store('altComiss');

$arrayRm1 = array_shift($array1);

$_SESSION["testPostSection1"] = $array1;

return redirect('alteracaocomissao');

}
}


Route:



Route::post('alteracaocomissao', 'PostController@AltComiss');


Testing code:



@php

session_start();

if (isset($_SESSION["testPostSection1"])) {

echo '<pre>'; print_r($_SESSION["testPostSection1"]); echo '</pre>';

}

@endphp


I do have SESSION there to test if the values are getting saved, because I still havn't set up the database, and until I do I'm using SESSION to test. Obviously once I set the database up I will switch from SESSION to inserting the values into the database.



Thanks in advance!










share|improve this question






















  • I think if you try application/x-www-form-urlencoded instead for your enctype, it might work. i vaguely recall reading about this a while ago.
    – noid
    Nov 8 at 10:56






  • 1




    @noid — That's the default, so is what they were using when they removed the enctype attribute. The form includes an input with type=file. That is incompatible with application/x-www-form-urlencoded
    – Quentin
    Nov 8 at 11:03












  • Yes, as mentioned, I did use the default and I was getting the data saved and shown in the SESSION. But doing that, I do not get the uploaded file. While if I change to multipart, I do get the file but I don't get the SESSION data.
    – JohnyJohnson
    Nov 8 at 11:10













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm working with Forms on Laravel, and I'm still learning. I thought I had it all figured out already, but I've been alted by an issue:



When I have enctype="multipart/form-data", I can't get the input values. The file I upload still gets uploaded to the disk, but the rest of the values are not printed. If I remove enctype="multipart/form-data", I do get the values.



Form:



<form id="forms" method="POST" action="alteracaocomissao" enctype="multipart/form-data">

{{ csrf_field() }}

<div class="form-row">
<div class="form-group col-md-6">
<label for="nomeentidade">Nome:</label>
<input type="text" class="form-control" id="nome1" name="nome1" placeholder="Nome entidade" required>

</div>
<div class="form-group col-md-6">
<label for="numentidade">Nº:</label>
<input type="text" class="form-control" id="num1" name="num1" placeholder="Número" required>
</div>
</div>

<div class="form-row">
<div class="form-group col-md-6 mb-3">
<label for="conta">Conta:</label>
<input type="text" class="form-control" id="conta" name="conta" placeholder="Conta" required>
</div>

<div class="form-group col-md-3 mb-3">
<label for="balcao">Local:</label>
<select class="form-control" id="local1" name="local1" required>
<option value="">Escolher...</option>
<option value="1">Local</option>
<option value="2">Local1</option>
</select>
</div>

<div class="form-group col-md-3 mb-3">
<label for="atleracao">Tipo de alteração:</label>
<select class="form-control" id="alteracao" name="alteracao" required>
<option value="">Escolher...</option>
<option value="1">Alterar1</option>
<option value="2">Alterar2</option>
</select>
</div>
</div>

<hr>

<div class="form-row" id="buildyourform">
<div class="form-group col-md-4">
<label for="comissao">TEST:</label>
<select class="form-control" id="TEST1" name="TEST1" required>
<option value="">Escolher...</option>
<option value="1">TEST</option>
<option value="2">TEST1</option>
</select>
</div>

<div class="form-group col-md-2">
<label for="desconto">Desconto solicitado:</label>
<div class="input-group">
<input type="text" class="form-control" id="desconto" name="desconto" placeholder="Número" required>
<span class=input-group-addon>%</span>
</div>
</div>

<div class="form-group col-md-2">
<label for="add"> &nbsp </label>
<input type="button" value="Adicionar campos" class="form-control btn btn-light" id="add" />
</div>

<div class="form-group col-md-1" id="2field">
<label for="remove"> &nbsp </label>
<input type="button" value="Remover" class="form-control btn btn-light" id="remove" />
</div>

<div class="form-group col-md-2">
</div>
</div>

<hr>

<div class="form-row">

<div class="form-group col-md-12">
<label for="fundamentacao">Fundamentação:</label>
<textarea type="text" class="form-control" id="fundamentacao" name="fundamentacao" placeholder="Fundamentação do pedido" required></textarea>
</div>

</div>

<div class="form-row">
<div class="form-group col-md-2">
<label for="file2">Anexo:</label>
<input type="file" name="file2" id="file2" required>

</div>
</div>

<hr>

<button type="submit" class="btn btn-primary">Enviar</button>
</form>


Controller:



namespace AppHttpControllers;

use IlluminateHttpRequest;

class PostController extends Controller
{

public function AltComiss(Request $request)
{
session_start();

$array1 = $request -> all();
$path = $request->file('file2')->store('altComiss');

$arrayRm1 = array_shift($array1);

$_SESSION["testPostSection1"] = $array1;

return redirect('alteracaocomissao');

}
}


Route:



Route::post('alteracaocomissao', 'PostController@AltComiss');


Testing code:



@php

session_start();

if (isset($_SESSION["testPostSection1"])) {

echo '<pre>'; print_r($_SESSION["testPostSection1"]); echo '</pre>';

}

@endphp


I do have SESSION there to test if the values are getting saved, because I still havn't set up the database, and until I do I'm using SESSION to test. Obviously once I set the database up I will switch from SESSION to inserting the values into the database.



Thanks in advance!










share|improve this question













I'm working with Forms on Laravel, and I'm still learning. I thought I had it all figured out already, but I've been alted by an issue:



When I have enctype="multipart/form-data", I can't get the input values. The file I upload still gets uploaded to the disk, but the rest of the values are not printed. If I remove enctype="multipart/form-data", I do get the values.



Form:



<form id="forms" method="POST" action="alteracaocomissao" enctype="multipart/form-data">

{{ csrf_field() }}

<div class="form-row">
<div class="form-group col-md-6">
<label for="nomeentidade">Nome:</label>
<input type="text" class="form-control" id="nome1" name="nome1" placeholder="Nome entidade" required>

</div>
<div class="form-group col-md-6">
<label for="numentidade">Nº:</label>
<input type="text" class="form-control" id="num1" name="num1" placeholder="Número" required>
</div>
</div>

<div class="form-row">
<div class="form-group col-md-6 mb-3">
<label for="conta">Conta:</label>
<input type="text" class="form-control" id="conta" name="conta" placeholder="Conta" required>
</div>

<div class="form-group col-md-3 mb-3">
<label for="balcao">Local:</label>
<select class="form-control" id="local1" name="local1" required>
<option value="">Escolher...</option>
<option value="1">Local</option>
<option value="2">Local1</option>
</select>
</div>

<div class="form-group col-md-3 mb-3">
<label for="atleracao">Tipo de alteração:</label>
<select class="form-control" id="alteracao" name="alteracao" required>
<option value="">Escolher...</option>
<option value="1">Alterar1</option>
<option value="2">Alterar2</option>
</select>
</div>
</div>

<hr>

<div class="form-row" id="buildyourform">
<div class="form-group col-md-4">
<label for="comissao">TEST:</label>
<select class="form-control" id="TEST1" name="TEST1" required>
<option value="">Escolher...</option>
<option value="1">TEST</option>
<option value="2">TEST1</option>
</select>
</div>

<div class="form-group col-md-2">
<label for="desconto">Desconto solicitado:</label>
<div class="input-group">
<input type="text" class="form-control" id="desconto" name="desconto" placeholder="Número" required>
<span class=input-group-addon>%</span>
</div>
</div>

<div class="form-group col-md-2">
<label for="add"> &nbsp </label>
<input type="button" value="Adicionar campos" class="form-control btn btn-light" id="add" />
</div>

<div class="form-group col-md-1" id="2field">
<label for="remove"> &nbsp </label>
<input type="button" value="Remover" class="form-control btn btn-light" id="remove" />
</div>

<div class="form-group col-md-2">
</div>
</div>

<hr>

<div class="form-row">

<div class="form-group col-md-12">
<label for="fundamentacao">Fundamentação:</label>
<textarea type="text" class="form-control" id="fundamentacao" name="fundamentacao" placeholder="Fundamentação do pedido" required></textarea>
</div>

</div>

<div class="form-row">
<div class="form-group col-md-2">
<label for="file2">Anexo:</label>
<input type="file" name="file2" id="file2" required>

</div>
</div>

<hr>

<button type="submit" class="btn btn-primary">Enviar</button>
</form>


Controller:



namespace AppHttpControllers;

use IlluminateHttpRequest;

class PostController extends Controller
{

public function AltComiss(Request $request)
{
session_start();

$array1 = $request -> all();
$path = $request->file('file2')->store('altComiss');

$arrayRm1 = array_shift($array1);

$_SESSION["testPostSection1"] = $array1;

return redirect('alteracaocomissao');

}
}


Route:



Route::post('alteracaocomissao', 'PostController@AltComiss');


Testing code:



@php

session_start();

if (isset($_SESSION["testPostSection1"])) {

echo '<pre>'; print_r($_SESSION["testPostSection1"]); echo '</pre>';

}

@endphp


I do have SESSION there to test if the values are getting saved, because I still havn't set up the database, and until I do I'm using SESSION to test. Obviously once I set the database up I will switch from SESSION to inserting the values into the database.



Thanks in advance!







php laravel forms






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 at 10:48









JohnyJohnson

8117




8117












  • I think if you try application/x-www-form-urlencoded instead for your enctype, it might work. i vaguely recall reading about this a while ago.
    – noid
    Nov 8 at 10:56






  • 1




    @noid — That's the default, so is what they were using when they removed the enctype attribute. The form includes an input with type=file. That is incompatible with application/x-www-form-urlencoded
    – Quentin
    Nov 8 at 11:03












  • Yes, as mentioned, I did use the default and I was getting the data saved and shown in the SESSION. But doing that, I do not get the uploaded file. While if I change to multipart, I do get the file but I don't get the SESSION data.
    – JohnyJohnson
    Nov 8 at 11:10


















  • I think if you try application/x-www-form-urlencoded instead for your enctype, it might work. i vaguely recall reading about this a while ago.
    – noid
    Nov 8 at 10:56






  • 1




    @noid — That's the default, so is what they were using when they removed the enctype attribute. The form includes an input with type=file. That is incompatible with application/x-www-form-urlencoded
    – Quentin
    Nov 8 at 11:03












  • Yes, as mentioned, I did use the default and I was getting the data saved and shown in the SESSION. But doing that, I do not get the uploaded file. While if I change to multipart, I do get the file but I don't get the SESSION data.
    – JohnyJohnson
    Nov 8 at 11:10
















I think if you try application/x-www-form-urlencoded instead for your enctype, it might work. i vaguely recall reading about this a while ago.
– noid
Nov 8 at 10:56




I think if you try application/x-www-form-urlencoded instead for your enctype, it might work. i vaguely recall reading about this a while ago.
– noid
Nov 8 at 10:56




1




1




@noid — That's the default, so is what they were using when they removed the enctype attribute. The form includes an input with type=file. That is incompatible with application/x-www-form-urlencoded
– Quentin
Nov 8 at 11:03






@noid — That's the default, so is what they were using when they removed the enctype attribute. The form includes an input with type=file. That is incompatible with application/x-www-form-urlencoded
– Quentin
Nov 8 at 11:03














Yes, as mentioned, I did use the default and I was getting the data saved and shown in the SESSION. But doing that, I do not get the uploaded file. While if I change to multipart, I do get the file but I don't get the SESSION data.
– JohnyJohnson
Nov 8 at 11:10




Yes, as mentioned, I did use the default and I was getting the data saved and shown in the SESSION. But doing that, I do not get the uploaded file. While if I change to multipart, I do get the file but I don't get the SESSION data.
– JohnyJohnson
Nov 8 at 11:10












1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










I think it's will help you



use IlluminateHttpRequest;

//use these For Start your session and Store file
use IlluminateSupportFacadesSession;
use IlluminateSupportFacadesStorage;


class PostController extends Controller{
public function AltComiss(Request $request){
$array1 = $request->all();

if ($request->hasFile('file2')) {
$file = $request->file('file2');
$destinationPath = 'altComiss';
$file->move($destinationPath,$file->getClientOriginalName());
}

$arrayRm1 = array_shift($array1);

Session::flash('allInput',$arrayRm1);
return redirect('alteracaocomissao');
}


}



On your view file for get the session data just use



@if (Session::has('allInput'))
<?php
echo '<pre>';
print_r(Session::get('allInput'));
echo '</pre>';
?>
@endif





share|improve this answer























  • This reads more like a game of spot-the-difference than an answer. What did you change? Why should it solve the problem?
    – Quentin
    Nov 8 at 11:02










  • I do see a couple of things there that I was also trying to accomplish. Thanks, I'm sure this will help. While testing I did get an error here "$file->move($destinationPath,$file->getClientOriginalName(););", I removed the ";" after OriginalName and the error was removed. The thing is, the files are not being saved, and I'm not getting the session data either.(its my first time using session flash, should I also echo $_SESSION['allInput']? I did do it and still not data)
    – JohnyJohnson
    Nov 8 at 11:09










  • I changed the "move" on that line that I was getting an error to "storeAs", and now I do get the file saved(which is great). But still, not SESSION data tho, so the problem remains unfortunatly
    – JohnyJohnson
    Nov 8 at 11:12










  • I have just updated my code . Please let me know whats happend now. Please create a folder on your project root "altComiss" for store your file
    – MD. Jubair Mizan
    Nov 8 at 11:15








  • 1




    Your answer did help me get to the right path, altho it was conceived more in the comments. I will accept, and hopefully if someone looks for this they will check the comments. I still have to figure out how to make sure I get the data from all inputs the user might add, but I'll figure that one out. Thanks again! Cheers
    – JohnyJohnson
    Nov 8 at 14:01











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206144%2fcant-get-input-values-with-enctype-multipart-form-data%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










I think it's will help you



use IlluminateHttpRequest;

//use these For Start your session and Store file
use IlluminateSupportFacadesSession;
use IlluminateSupportFacadesStorage;


class PostController extends Controller{
public function AltComiss(Request $request){
$array1 = $request->all();

if ($request->hasFile('file2')) {
$file = $request->file('file2');
$destinationPath = 'altComiss';
$file->move($destinationPath,$file->getClientOriginalName());
}

$arrayRm1 = array_shift($array1);

Session::flash('allInput',$arrayRm1);
return redirect('alteracaocomissao');
}


}



On your view file for get the session data just use



@if (Session::has('allInput'))
<?php
echo '<pre>';
print_r(Session::get('allInput'));
echo '</pre>';
?>
@endif





share|improve this answer























  • This reads more like a game of spot-the-difference than an answer. What did you change? Why should it solve the problem?
    – Quentin
    Nov 8 at 11:02










  • I do see a couple of things there that I was also trying to accomplish. Thanks, I'm sure this will help. While testing I did get an error here "$file->move($destinationPath,$file->getClientOriginalName(););", I removed the ";" after OriginalName and the error was removed. The thing is, the files are not being saved, and I'm not getting the session data either.(its my first time using session flash, should I also echo $_SESSION['allInput']? I did do it and still not data)
    – JohnyJohnson
    Nov 8 at 11:09










  • I changed the "move" on that line that I was getting an error to "storeAs", and now I do get the file saved(which is great). But still, not SESSION data tho, so the problem remains unfortunatly
    – JohnyJohnson
    Nov 8 at 11:12










  • I have just updated my code . Please let me know whats happend now. Please create a folder on your project root "altComiss" for store your file
    – MD. Jubair Mizan
    Nov 8 at 11:15








  • 1




    Your answer did help me get to the right path, altho it was conceived more in the comments. I will accept, and hopefully if someone looks for this they will check the comments. I still have to figure out how to make sure I get the data from all inputs the user might add, but I'll figure that one out. Thanks again! Cheers
    – JohnyJohnson
    Nov 8 at 14:01















up vote
0
down vote



accepted










I think it's will help you



use IlluminateHttpRequest;

//use these For Start your session and Store file
use IlluminateSupportFacadesSession;
use IlluminateSupportFacadesStorage;


class PostController extends Controller{
public function AltComiss(Request $request){
$array1 = $request->all();

if ($request->hasFile('file2')) {
$file = $request->file('file2');
$destinationPath = 'altComiss';
$file->move($destinationPath,$file->getClientOriginalName());
}

$arrayRm1 = array_shift($array1);

Session::flash('allInput',$arrayRm1);
return redirect('alteracaocomissao');
}


}



On your view file for get the session data just use



@if (Session::has('allInput'))
<?php
echo '<pre>';
print_r(Session::get('allInput'));
echo '</pre>';
?>
@endif





share|improve this answer























  • This reads more like a game of spot-the-difference than an answer. What did you change? Why should it solve the problem?
    – Quentin
    Nov 8 at 11:02










  • I do see a couple of things there that I was also trying to accomplish. Thanks, I'm sure this will help. While testing I did get an error here "$file->move($destinationPath,$file->getClientOriginalName(););", I removed the ";" after OriginalName and the error was removed. The thing is, the files are not being saved, and I'm not getting the session data either.(its my first time using session flash, should I also echo $_SESSION['allInput']? I did do it and still not data)
    – JohnyJohnson
    Nov 8 at 11:09










  • I changed the "move" on that line that I was getting an error to "storeAs", and now I do get the file saved(which is great). But still, not SESSION data tho, so the problem remains unfortunatly
    – JohnyJohnson
    Nov 8 at 11:12










  • I have just updated my code . Please let me know whats happend now. Please create a folder on your project root "altComiss" for store your file
    – MD. Jubair Mizan
    Nov 8 at 11:15








  • 1




    Your answer did help me get to the right path, altho it was conceived more in the comments. I will accept, and hopefully if someone looks for this they will check the comments. I still have to figure out how to make sure I get the data from all inputs the user might add, but I'll figure that one out. Thanks again! Cheers
    – JohnyJohnson
    Nov 8 at 14:01













up vote
0
down vote



accepted







up vote
0
down vote



accepted






I think it's will help you



use IlluminateHttpRequest;

//use these For Start your session and Store file
use IlluminateSupportFacadesSession;
use IlluminateSupportFacadesStorage;


class PostController extends Controller{
public function AltComiss(Request $request){
$array1 = $request->all();

if ($request->hasFile('file2')) {
$file = $request->file('file2');
$destinationPath = 'altComiss';
$file->move($destinationPath,$file->getClientOriginalName());
}

$arrayRm1 = array_shift($array1);

Session::flash('allInput',$arrayRm1);
return redirect('alteracaocomissao');
}


}



On your view file for get the session data just use



@if (Session::has('allInput'))
<?php
echo '<pre>';
print_r(Session::get('allInput'));
echo '</pre>';
?>
@endif





share|improve this answer














I think it's will help you



use IlluminateHttpRequest;

//use these For Start your session and Store file
use IlluminateSupportFacadesSession;
use IlluminateSupportFacadesStorage;


class PostController extends Controller{
public function AltComiss(Request $request){
$array1 = $request->all();

if ($request->hasFile('file2')) {
$file = $request->file('file2');
$destinationPath = 'altComiss';
$file->move($destinationPath,$file->getClientOriginalName());
}

$arrayRm1 = array_shift($array1);

Session::flash('allInput',$arrayRm1);
return redirect('alteracaocomissao');
}


}



On your view file for get the session data just use



@if (Session::has('allInput'))
<?php
echo '<pre>';
print_r(Session::get('allInput'));
echo '</pre>';
?>
@endif






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 8 at 11:14

























answered Nov 8 at 10:58









MD. Jubair Mizan

696




696












  • This reads more like a game of spot-the-difference than an answer. What did you change? Why should it solve the problem?
    – Quentin
    Nov 8 at 11:02










  • I do see a couple of things there that I was also trying to accomplish. Thanks, I'm sure this will help. While testing I did get an error here "$file->move($destinationPath,$file->getClientOriginalName(););", I removed the ";" after OriginalName and the error was removed. The thing is, the files are not being saved, and I'm not getting the session data either.(its my first time using session flash, should I also echo $_SESSION['allInput']? I did do it and still not data)
    – JohnyJohnson
    Nov 8 at 11:09










  • I changed the "move" on that line that I was getting an error to "storeAs", and now I do get the file saved(which is great). But still, not SESSION data tho, so the problem remains unfortunatly
    – JohnyJohnson
    Nov 8 at 11:12










  • I have just updated my code . Please let me know whats happend now. Please create a folder on your project root "altComiss" for store your file
    – MD. Jubair Mizan
    Nov 8 at 11:15








  • 1




    Your answer did help me get to the right path, altho it was conceived more in the comments. I will accept, and hopefully if someone looks for this they will check the comments. I still have to figure out how to make sure I get the data from all inputs the user might add, but I'll figure that one out. Thanks again! Cheers
    – JohnyJohnson
    Nov 8 at 14:01


















  • This reads more like a game of spot-the-difference than an answer. What did you change? Why should it solve the problem?
    – Quentin
    Nov 8 at 11:02










  • I do see a couple of things there that I was also trying to accomplish. Thanks, I'm sure this will help. While testing I did get an error here "$file->move($destinationPath,$file->getClientOriginalName(););", I removed the ";" after OriginalName and the error was removed. The thing is, the files are not being saved, and I'm not getting the session data either.(its my first time using session flash, should I also echo $_SESSION['allInput']? I did do it and still not data)
    – JohnyJohnson
    Nov 8 at 11:09










  • I changed the "move" on that line that I was getting an error to "storeAs", and now I do get the file saved(which is great). But still, not SESSION data tho, so the problem remains unfortunatly
    – JohnyJohnson
    Nov 8 at 11:12










  • I have just updated my code . Please let me know whats happend now. Please create a folder on your project root "altComiss" for store your file
    – MD. Jubair Mizan
    Nov 8 at 11:15








  • 1




    Your answer did help me get to the right path, altho it was conceived more in the comments. I will accept, and hopefully if someone looks for this they will check the comments. I still have to figure out how to make sure I get the data from all inputs the user might add, but I'll figure that one out. Thanks again! Cheers
    – JohnyJohnson
    Nov 8 at 14:01
















This reads more like a game of spot-the-difference than an answer. What did you change? Why should it solve the problem?
– Quentin
Nov 8 at 11:02




This reads more like a game of spot-the-difference than an answer. What did you change? Why should it solve the problem?
– Quentin
Nov 8 at 11:02












I do see a couple of things there that I was also trying to accomplish. Thanks, I'm sure this will help. While testing I did get an error here "$file->move($destinationPath,$file->getClientOriginalName(););", I removed the ";" after OriginalName and the error was removed. The thing is, the files are not being saved, and I'm not getting the session data either.(its my first time using session flash, should I also echo $_SESSION['allInput']? I did do it and still not data)
– JohnyJohnson
Nov 8 at 11:09




I do see a couple of things there that I was also trying to accomplish. Thanks, I'm sure this will help. While testing I did get an error here "$file->move($destinationPath,$file->getClientOriginalName(););", I removed the ";" after OriginalName and the error was removed. The thing is, the files are not being saved, and I'm not getting the session data either.(its my first time using session flash, should I also echo $_SESSION['allInput']? I did do it and still not data)
– JohnyJohnson
Nov 8 at 11:09












I changed the "move" on that line that I was getting an error to "storeAs", and now I do get the file saved(which is great). But still, not SESSION data tho, so the problem remains unfortunatly
– JohnyJohnson
Nov 8 at 11:12




I changed the "move" on that line that I was getting an error to "storeAs", and now I do get the file saved(which is great). But still, not SESSION data tho, so the problem remains unfortunatly
– JohnyJohnson
Nov 8 at 11:12












I have just updated my code . Please let me know whats happend now. Please create a folder on your project root "altComiss" for store your file
– MD. Jubair Mizan
Nov 8 at 11:15






I have just updated my code . Please let me know whats happend now. Please create a folder on your project root "altComiss" for store your file
– MD. Jubair Mizan
Nov 8 at 11:15






1




1




Your answer did help me get to the right path, altho it was conceived more in the comments. I will accept, and hopefully if someone looks for this they will check the comments. I still have to figure out how to make sure I get the data from all inputs the user might add, but I'll figure that one out. Thanks again! Cheers
– JohnyJohnson
Nov 8 at 14:01




Your answer did help me get to the right path, altho it was conceived more in the comments. I will accept, and hopefully if someone looks for this they will check the comments. I still have to figure out how to make sure I get the data from all inputs the user might add, but I'll figure that one out. Thanks again! Cheers
– JohnyJohnson
Nov 8 at 14:01


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206144%2fcant-get-input-values-with-enctype-multipart-form-data%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff