CodeIgniter Forums
Cant get photo to upload. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Cant get photo to upload. (/showthread.php?tid=77675)

Pages: 1 2


RE: Cant get photo to upload. - InsiteFX - 10-03-2020

The CodeIgniter User Guide shows how to do this.

Do this, otherwise go by the User Guide and start over.

PHP Code:
// change this
public function drinkadvert()

// to this
public function do_upload() 



RE: Cant get photo to upload. - christaliise - 10-04-2020

(10-03-2020, 10:20 AM)InsiteFX Wrote: What is the name of the controller that the function is in?

PHP Code:
<?php echo form_open_multipart('controllerName/drinkadvert'); ?>

Change controllerName to the name of your controller that the drinkadvert is in.

Ive found what I think was an error. The working page that has these functions have the following variable with a different name;

PHP Code:
$drinkphoto 'mem/'.$lcuser.'/adverts/'.$drink/$img['file_name'];
$drinkpic 'mem/'.$lcuser.'/adverts/'.$drink/$img['file_name'];

if(isset(
$_FILES['drinkphoto']['name']) && $_FILES['drinkphoto']['name']!="")
if(isset(
$_FILES['drinkpic']['name']) && $_FILES['drinkpic']['name']!="")

$mime get_mime_by_extension($_FILES['drinkphoto']['name']);
$mime get_mime_by_extension($_FILES['drinkpic']['name']); 

But that did not solve my problem. However, it may lead to a resolution.


RE: Cant get photo to upload. - coder987 - 10-12-2020

I also had a similar situation


RE: Cant get photo to upload. - christaliise - 11-16-2020

Ive found the root of my problem but not solved it.

I am able to upload fwrite data then redirect to photos upload, but the problem with that is if the $product name is omitted or different the fwrite & photos are not together, and that is unsatisfactory. I would prefer to have both in the same operation but that is impossible. The root of that problem is in the view page where the fwrite requires the first coding & the photo upload requires the second, and they are not interchangeable.

PHP Code:
<?php echo form_open('pagename'); ?>
<?php 
echo form_open_multipart('pagename'); ?>

If the $product variable in the fwrite can be transferred to the photos upload, then that could be lived with, but redirect to the finished advert will be required.

I would prefer when the photos are uploaded then to redirect to the finished advert, but that is impossible because the photos upload will not redirect. Although I have another operation with a small amount of fwrite plus a pdf document upload and that redirects with no problem.

I have spent the last 4 months trying to resolve this issue, probably spent 1,000 hours plus, and still havent achieved a resolution.

By the way the coding in the UserGuide detailing uploads is faulty, by undefined variables, but when those variables are deleted it works but not with a combination of fwrite & photo uploads.

The problem appears to be a fault within CodeIgniter, so there needs to be someone who understands their coding & be able to fix the problem.


RE: Cant get photo to upload. - christaliise - 12-02-2020

Ive found the problem. When uploading data with photos you must keep separate in form_validation the data from photos. Just make two separate form_validations.