This topic is locked

Renaming uploaded images question

3/24/2006 11:30:46 AM
PHPRunner General questions
D
dsaunier author

Hello to the visitors and creators of that great soft;
I have a question about uploading pix, as they'll be used by our PHP application to illustrate goods for sale, and we need a way to identificate which picture is for which good.

The way it works now it seems to me the original picture name remains unchanged, but in that case our PHP site has no way of knowing which image goes with which new record.

Hence, as we have 3 upload fields for each good, I need with PHPrunner a way to have an uploaded image take a name based on another field called "reference".

I have no problem adding custom PHP code to some files if required, I just need help on how to have that if we create a new record with "1234" in the reference field, then that the first uploaded image is called 1234_1.jpg, #2 (if it exists) 1234_2.jpg etc, and further editing of the record should keep the same naming. Provided the image names are good, our PHP site will take it from there to resize images, sort them out in the correct folders etc.

I hope this is doable as I like the soft a lot and would be sorry to have to develop something else from scratch just to manage images.
Thanks.

Sergey Kornilov admin 3/27/2006

Hi,
you can change file name manually in the Filename box on the ADD/EDIT page.
If you want to fill this field automatically, open include/..._function.php file, find

$file_move = array($file['tmp_name'],GetUploadFolder($field).$value);



and place your code before this line.

You can put the correct file name in $value variable.

D
dsaunier author 3/27/2006

Thanks, the idea seems good, do you know however how I could "grab" the correct field name from the upload form to rename my picture on-the-fly ?

I now seem to have other upload issues on that Plesk server, has anybody ever had an upload error with PHPRunner that says
move_uploaded_file(): open_basedir restriction in effect. File(/upload/mytest.jpg) is not within the allowed path(s): (/home/httpd/vhosts/domainhere/httpdocs:/tmp)
?

The weird thing is, this only happens with my 2nd and 3rd upload field whereas I have no problem uploading a 2.5 Mb picture for my "image1" field ! All 3 fields are absolutely the same and specified as "file download" for both "view as" and "edit as". All 3 upload to "upload/" which is CHmoded 777 and in which my image1 upload does exactly as expected.
Thanks.

Sergey Kornilov admin 3/28/2006

Hi,

  1. you can get the field name in the following way:
    $_POST["value".array_search("reference",$fieldlist)]



where reference is your current field name.

But this code will work in case of this field is on the EDIT page.
2. It seems that you type incorrect path to subfolder where files reside. The path should be relative to the folder for generated pages.

Type

upload/

in the Folder where files reside box on the Edit as dialog on the Formatting Tab.

D
dsaunier author 1/29/2007

Hello Alexey
This message is because a few months ago we exchanged emails and paid your time to have a small custom change done, so that uploaded images were named after the record they belong to (as following problem detailed in the post above). I have now updated my PHPrunner to Build 207 and recreated pages, but it seems the code stopped working.

What should I change and where, so that uploaded images are named properly ?
Best regards.

Hi,


  1. you can get the field name in the following way:
    where reference is your current field name.

    But this code will work in case of this field is on the EDIT page.
  2. It seems that you type incorrect path to subfolder where files reside. The path should be relative to the folder for generated pages.

    Type

    upload/

    in the Folder where files reside box on the Edit as dialog on the Formatting Tab.

D
dsaunier author 1/30/2007

Not sure if that question was received by email, and I must complete this project tomorrow, so bumping this thread, thanks.

Sergey Kornilov admin 1/30/2007

For questions like this you need to contact support directly.
http://www.asprunner.com/forums/index.php?showtopic=4497

D
dsaunier author 1/30/2007

I have but got no reply for that unfortunately urgent need, and as we've had email issues before, I thought this was a safe reminder ;-)

Best regards.

For questions like this you need to contact support directly.

http://www.asprunner.com/forums/index.php?showtopic=4497

Sergey Kornilov admin 1/31/2007

I don't even know what address your email should be coming from.

No unanswered emails at this point. Please resend.