Post by martyn » Sun Mar 11, 2007 12:47 am

Hi,

I've installed opencart v0.6 on my local desktop running apache2, php5 and mysql4. All seems to be working ok but I am having problems uploading image files. When I want to add a new image, I specify the name/title and then browse to the image file and click 'save'. Unfortunately, nothing gets added. I've tracked the code and found the problem to be in admin/plugin/image.php on line 47. It appears move_uploaded_file() seems to fail and hence nothing is added. I've tried to debug what's going on by adding the following:

Code: Select all

if ($_POST['task'] == 'insert') {
    	?>$_FILES: <?=print_r($_FILES)?>.<?
    	?>$_POST: <?=print_r($_POST)?>.<?
    	?>is_uploaded_file()?: '<?=is_uploaded_file($_FILES['image']['tmp_name'])?>'.<?
    	?>moving uploaded file ... from: '<?=$_FILES['image']['tmp_name']?>' to '<?=DIR_IMAGE . basename($_FILES['image']['name'])?>'.<?
      if ($x = move_uploaded_file($_FILES['image']['tmp_name'], DIR_IMAGE . basename($_FILES['image']['name']))) { ...
This outputs:

Code: Select all

$_FILES: Array
(
    [image] => Array
        (
            [name] => 73.orig.jpg
            [type] => image/jpeg
            [tmp_name] => E:/php-5.1.4/tmp/php29.tmp
            [error] => 0
            [size] => 184506
        )

)
1.$_POST: Array
(
    [title] => Array
        (
            [1] => 022FM
        )

    [task] => insert
)
1.is_uploaded_file()?: ''.moving uploaded file ... from: 'E:/php-5.1.4/tmp/php29.tmp' to 'E:/Projects/opencart06/image/73.orig.jpg'.x: ''.<br />
<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at E:\Projects\opencart06\admin\plugin\image.php:47) in <b>E:\Projects\opencart06\admin\plugin\image.php</b> on line <b>65</b><br />
The warning at the end is fair enough.

error_reporting is set to E_ALL and nothing is output.

I'm guessing this is some kind of environment problem because I've got opencart installed on a separate web server and image uploads work fine. However, I have another site I have developed running off the same web server that handles file uploads fine!

If anyone has an answer or had a similar problem, please let me know. I'm going to try continue to solve it so if I find an answer before anyone else, I'll let you know.

Thanks,
Martyn.
     

Newbie

Posts

Joined
Sun Mar 11, 2007 12:31 am

Post by Daniel » Mon Mar 12, 2007 7:37 pm

Could it be file size limit in the php ini?

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by martyn » Wed Mar 14, 2007 12:30 am

file_size_limit is 2M
post_max_size is 8M

more than enough for images of 100k

Newbie

Posts

Joined
Sun Mar 11, 2007 12:31 am

Post by martyn » Wed Mar 14, 2007 12:49 am

and just for good measure, i created this test script, saved in the admin directory of the opencart app and the file upload works but image uploads in opencart still doesnt!  :'( How strange!

Code: Select all

<?
if($_POST['action'] == "upload") {

    move_uploaded_file($_FILES['image']['tmp_name'], "e:/projects/opencart06/image/test.jpg");
    ?> moved uploaded file <?
} else {
    ?>
    <form enctype="multipart/form-data" method="POST">
    <input type="file" name="image">
    
    <input type="submit" name="action" value="upload">
    </form>
    <?
}
?>

Newbie

Posts

Joined
Sun Mar 11, 2007 12:31 am

Post by martyn » Wed Mar 14, 2007 6:03 am

Solved it!

I tracked it to include/database.php in the constructor. Basically Magic Quotes GPC was set to On when they should be Off.

Newbie

Posts

Joined
Sun Mar 11, 2007 12:31 am
Who is online

Users browsing this forum: No registered users and 2 guests