Welcome Guest, Not a member yet? Register   Sign In
Simple file upload with other input fields not working
#1

[eluser]Unknown[/eluser]
Hello Experts,


Trying to implement 'file upload' with other input fields .. file upload without other fields is working fine but with other fields the form is not executing once i click on the 'submit' button in the form.

Kindly help me out, thanks in advance.




View Code



<html>
<head>
<title>Upload Form</title>
</head>
<body>

<?php echo $error;?>

<?php echo form_open_multipart('upload/do_upload');?>

<h5>Upload Image</h5>
&lt;input type="file" name="userfile" size="20" /&gt;

<h5>Text Field</h5>
&lt;input type="text" name="var1" size="20" /&gt;


<br /><br />

&lt;input type="submit" value="upload" /&gt;

&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;


Controller code

&lt;?php

class Upload extends Controller {

function Upload()
{
parent::Controller();
$this->load->helper(array('form', 'url'));
}

function index()
{
// echo "<BR>".$path."<BR>";
$this->load->view('form_upload', array('error' => ' ' ));
}

function do_upload()
{
$this->load->model('mproducts');

$path = $_SERVER["DOCUMENT_ROOT"].'/ciprojects/ibmcibasics/system/application/uploads/';
$config['upload_path'] = $path;

$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';

$this->load->library('upload', $config);

if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());

$this->load->view('form_upload', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
// $this->mproducts->entry_insert();

$this->load->view('upload_success', $data);
}
}
}
?&gt;
#2

[eluser]Marlon Souza[/eluser]
swiftguy121,

Good Morning,
is missing the fildname Upload try this

&lt;input type="file" id="userfile" name="userfile"&gt;




Theme © iAndrew 2016 - Forum software by © MyBB