Re: A guide to image upload problems

hi all,

i have some questions on php file upload. i have used the following code to upload a file. but it show the error. i have try to set the
safe_mode = on
safe_mode_gid = off
in the php.ini.

Can anyone help me to answer this question?? thanks a lots  roll


<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.

$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];

print "<pre>";

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
   print "File is valid, and was successfully uploaded. ";
   print "Here's some more debugging info:\n";
   print_r($_FILES);
} else {
   print "Possible file upload attack!  Here's some debugging info:\n";
   print_r($_FILES);
}
print "</pre>";

?>

ERROR::
Warning:  SAFE MODE Restriction in effect.  The script whose uid is 522 is not allowed to access /var/www owned by uid 0 in /home/virtual/site20/fst/var/www/html/phptest/uploaded.php on line 10
Possible file upload attack!  Here's some debugging info:
Array
(
    [userfile] => Array
        (
            [name] => 243.pdf
            [type] => application/pdf
            [tmp_name] => /tmp/phpptQVTL
            [error] => 0
            [size] => 104616
        )

)

Re: A guide to image upload problems

Firstly, I cannot advise on server related questions because I do not have that knowledge.

There is another method which could be used to upload images - especially if you are running the store yourself.

Simply change the product form's 'file' fields to 'text' fields.

Then remove the validate_image() and process_images() function calls in ps_product.inc

Then you would...
1) Name all your product images uniquely on your local machine (maybe using the sku)
2) FTP all the images to the product folder
3) In the product form, enter the file name into the text fields.

Would speed up product adding, but has the potential for error when typing the name into the field. Would also potentially allow the use of the same image for more than one product.

-John


Thanks John !
That's what I did.
I got rid of the validate and process images function calls in ps_product.inc
and in product_form.ihtml I changed type="file" to type="text" and added a value attribute like this:

<input type="text" name="product_thumb_image" size="32" value="<?php $db->sp("product_thumb_image"); ?>" maxlength="255" />

<input type="text" name="product_full_image" size="32" value="<?php $db->sp("product_full_image"); ?>" maxlength="255" />

As you can see I added

value="<?php $db->sp("product_thumb_image"); ?>"

in the input forms so that the name of the file will be there from the database and stay in the field, otherwise every time I edited the product, the images got deleted.



I had to do that because I just couldn't get the upload to work.
I tried all the fixes proposed in the forums to no avail.
Maybe it's because I'm on Linux 2.6 kernel?

I'm using PHP 4.3.8, apache-1.3.31 on a Mandrake 10.1 Linux distribution.


Otherwise PhpShop is great!  Congrats to the developers!   wink

Cheers,
Orlin

Re: A guide to image upload problems

the errors i get have yet to be discussed on here. SO i thought maybe i should bring them up. I receive the following errors: ERROR: thumbnail image file is invalid.
ERROR: full image file is invalid
The image upload used to work but after there was a problem with the servers it quit working on it's own. I'm wondering if anyone can help me rectify the problem...

Thanks in advance.

Re: A guide to image upload problems

THIS IS RESOLVED SEE BELOW

Hi  :angry:

I have installed phpshop on Linux with php 4.3.10 for my local church, it is installed at non public level like this...

/phpshop
/public_ftp
/public_html
/ssl
/tmp
/www

The files at public level are in
/public_html/store

so the phpshop home page is at

/public_html/store/index.php

the issue I am having is that the images do upload but I just get the red X in the admin for Thumb Nail and Full Image and on the home page for products

I have applied all the fixes I could find in the forums to get it working to this point.... so I believe it is all working and that I just have a path to the images folder set wrong....

I believe this because when viewing the page source code the vendor logo (which appears) image path shows as (note the https)

SRC=https://www.church.com/store//images/shop/vendor/316b4d8a5a6053c6b398917b53ecbc98.jpg

(also not sure in which file to remove the extra / before the images folder) but anyway vendor logo is showing on the page

but the source code for home page product images path only shows as
SRC=/images/shop/product/4dd3f6d7912e8312bc9ae3b70c7777ed.jpg

Can anybody please assist with any ideas... I think I am very close to having it all work perfectly if I can just resolve this image issue... which I think is an easy path fix... but I cant seem to find where to apply it.

Thank you if you can help the church and me  big_smile

Jolanta
++++++++++++++++++++++
OK I HAVE FIXED THIS... SO FOR ANYBODY ELSE... I went into the MySQL using phpMyAdmin and opened the table vendor then went to browse and looked for column

upload_image_path

which had

/images/store/

change this to

images/store/

and your done.... good luck
++++++++++++++++++++++

Re: A guide to image upload problems

I'm new to phpshop.  I've got what I think is a simple error.  A problem with a '/' missing somewhere.  When I try to upload an image for a new project, the image doesn't get uploaded and the corresponding columns in the product table are empty.   When I try to delete and item I get this error:
ERROR: Cannot delete from thumbnail image directory.
/home/name/www/testimages/shop/product/

test is a directory and there is an '/' missing somewhere in the code it seems for the image upload and delete functions. 

If I change the directory in the vendor table to /images/shop then I can delete items but all the image links don't work.    (So ideally, I like to just add the '/' relating to the image upload and delete functions instead of all the other '/' elsewhere). 

Any ideas?

What file should I change?

Thanks in Advance.

Re: A guide to image upload problems

I still get image upload problems and I already followed the directions giving here *cries*

whenever i upload an image it displays this message

Warning: copy(C: mpp mp\phpD0.tmp) [function.copy]: failed to open stream: Invalid argument in C:\xampp\htdocs\beautybox\WEB-INF\modules\admin\lib\ps_main.inc(222) : eval()'d code on line 1

and this one
An error has ocurred.
ERROR: Image Update command failed.
$ret = copy("C:\xampp\tmp\phpD0.tmp", "C:/xampp/htdocs/beautybox/images/shop/product/3e0ec7678a73d7b5c2ba3de76e99a1d8.jpg")

Thanks in advance for your help