public function assignvartext() { $min = Input::get('min'); $max = Input::get('max'); $vid = Input::get('vid'); for ($i = $min; $i < $max + 1; $i++) { $varid = 'variableid-' . $i; $input = Input::get($varid); echo $input; $type = $this->variant->getVarType($i); if ($type == 5 || $type == 6) { $file = Input::file('variableid-' . $i); // your file upload input field in the form should be named 'file' $publicpath = public_path(); $landing = $this->variant->getfoldername($vid); $destinationPath = $publicpath . '/' . $landing; mkdir($destinationPath, 0755); $filename = $file->getClientOriginalName(); //$extension =$file->getClientOriginalExtension(); //if you need extension of the file $uploadSuccess = Input::file('variableid-' . $i)->move($destinationPath, $filename); $input = $destinationPath . '/' . $filename; } $this->variant->storeVartexts($i, $input); } $variant = $this->variant->find($vid); return Redirect::route('getVariants', array('lp_id' => $variant->lp_id)); }