This topic is locked
[SOLVED]

 PHPR 6.2 Image Upload ???

11/14/2012 6:15:37 AM
PHPRunner General questions
N
netmedia59 author

Hello,
Is there a way to have the old Image Upload system in PHPR 6.2

In other words, when I want to upload an image file ( 2012-11-12_103536.jpg ) in a directory (../logo_org) , in the field of the database I will have something like this :
[{"name":"..\/logo_org\/2012-11-12_103536_8yxpv5oe.jpg","usrName":"2012-11-12_103536.jpg","size":21214,"type":"image\/jpeg","searchStr":"2012-11-12_103536.jpg,!:sStrEnd"}]
which is unreadable by other systems

I want to have only : 2012-11-12_103536.jpg or 2012-11-12_103536_8yxpv5oe.jpg
Thanks
Olivier

Lille (FRANCE)

C
cgphp 11/14/2012

Sure, you can. Follow these steps:

  1. In the "Before record added" event enter the following code:

$arr = json_decode($values['your_image_field_name']);

$values['your_image_field_name'] = $arr[0]->name;

return true;



Replace your_image_field_name with the real name of the upload field.
2. Enable the "Use different settings for all pages" option in the editor, set the list page as Custom and enter the following code:

$value = '<img src="'.$value.'" />';
N
netmedia59 author 11/15/2012

Hey Cristian,
It seems to work

One little thing, as I want to upload in another directory (../logo_org), in the field I have ../logo_org/image.jpg

How can I avoid ../logo_org/
Thanks again !
Olivier

Lille (FRANCE)
PS : I'll contact you by MP, I need a script to send some Info by mail to selected contacts in a list



Sure, you can. Follow these steps:

  1. In the "Before record added" event enter the following code:

$arr = json_decode($values['your_image_field_name']);

$values['your_image_field_name'] = $arr[0]->name;

return true;



Replace your_image_field_name with the real name of the upload field.
2. Enable the "Use different settings for all pages" option in the editor, set the list page as Custom and enter the following code:

$value = '<img src="'.$value.'" />';


C
cgphp 11/15/2012
$arr = json_decode($values['your_image_field_name']);

$path_parts = pathinfo($arr[0]->name);

$values['your_image_field_name'] = $path_parts['filename'];

return true;
N
netmedia59 author 11/15/2012

Hey Cristian,
Almost working but I've lost the extension (eg : .jpg)

Thanks again
Olivier


$arr = json_decode($values['your_image_field_name']);

$path_parts = pathinfo($arr[0]->name);

$values['your_image_field_name'] = $path_parts['filename'];

return true;


C
cgphp 11/15/2012
$arr = json_decode($values['your_image_field_name']);

$path_parts = pathinfo($arr[0]->name);

$values['your_image_field_name'] = $path_parts['filename'] . '.' . $path_parts['extension'];

return true;
N
netmedia59 author 11/15/2012

Hey Cristan,
Thanks very much !

It's working as expected !

Sincerely
Olivier
PS : How can I contact you by mail ?


$arr = json_decode($values['your_image_field_name']);

$path_parts = pathinfo($arr[0]->name);

$values['your_image_field_name'] = $path_parts['filename'] . '.' . $path_parts['extension'];

return true;


C
cgphp 11/15/2012

You can send me a private message on this board, then I will contact you directly.

C
cgphp 11/15/2012

There is some problem with the board. I'm not able to answer to your comment. Please, leave a new comment on my profile indicating your email address.