[eluser]JimmyJ[/eluser]
Hey, wonering if anyone can give me a hand with this problem.
I'm trying to upload an image, but keep getting an error where $_FILES['userfile'] is not found.
My form looks like this:
Code:
<form id="form2" name="form2" method="post" action="/admin/pages/addgallery">
<fieldset>
<legend>Add a new image here</legend>
<label for="imageName">Image Name</label>
<input type="text" name="imageTitle" id="imageName" />
<label for="imageDesc">Image Description</label>
<input type="text" name="imageDesc" id="imageDesc" />
<label for="userfile">Image file</label>
<input name="userfile" type="file" id="browsefile" />
<input name="pageID" type="hidden" value="<?php echo $id; ?>" />
<input type="hidden" name="post_max_size" value="999999999999">
<input type="hidden" name="MAX_FILE_SIZE" value="999999999999">
<p> <input type="submit" name="addImage" id="button" value="Upload new image" /></p>
</fieldset>
</form>
And my upload code looks like this:
Code:
<?php
//echo $_SERVER['DOCUMENT_ROOT'];
print_r($_POST);
mysql_query("INSERT INTO gallery (pageID, imageTitle, imageDesc) VALUES ('$_POST[pageID]', '$_POST[imageTitle]', '$_POST[imageDesc]')");
$imageid = mysql_insert_id();
$folder = $_SERVER['DOCUMENT_ROOT'] . 'userFiles/gallery/large/';
$thumbFolder = $_SERVER['DOCUMENT_ROOT'] . 'userFiles/gallery/thumbs/';
if(!empty($_FILES['userfile'])){ echo '<p style="color:green">file detection successful</p>'; }
else { echo '<p style="color:red">file failed to upload</p>'; }
move_uploaded_file($_FILES['userfile']['tmp_name'], $folder.$imageid.".jpg");
if(file_exists($folder.$imageid.".jpg"))
{
$this->load->library();
chmod($folder.$imageid.".jpg", 0777);
$this->load->library('image_lib');
//UPLOAD
$config['upload_path'] = $folder;
$config['allowed_types'] = 'jpg';
$config['max_size'] = '5000';
$config['max_width'] = '1280';
$config['max_height'] = '1024';
$this->load->library('upload', $config);
// RESIZE
$config[] = 'GD2';
$config['source_image'] = $folder.$imageid.".jpg";
$config['maintain_ratio'] = FALSE;
$config['width'] = 490;
$config['height'] = 234;
$this->image_lib->clear();
$this->image_lib->initialize($config);
$this->image_lib->resize();
// THUMB
$config[] = 'GD2';
$config['source_image'] = $folder.$imageid.".jpg";
$config['new_image'] = $thumbFolder.$imageid.".jpg";
$config['maintain_ratio'] = TRUE;
$config['height'] = 118;
$config['width'] = 247;
$this->image_lib->clear();
$this->image_lib->initialize($config);
$this->image_lib->resize();
chmod($folder.$imageid."jpg", 0777);
//CROP THUMB
$config[] = 'GD2';
$config['source_image'] = $thumbFolder.$imageid.".jpg";
$config['x_axis'] = 109;
$config['y_axis'] = 11;
$this->image_lib->clear();
$this->image_lib->initialize($config);
$this->image_lib->crop();
}
die("<p>End</p>");
header("location: /admin/pages/modify/$_POST[pageID]");
?>
I'vve tried it on 2 different servers, checked my php.ini max size, plus put in the hidden fields but it still won't find userfile. It find's the post data ok, so i'm confused!
Anyone have any ideas?