TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Image folders problems (http://www.talkphp.com/absolute-beginners/1750-image-folders-problems.html)

Filipe Costa 12-16-2007 07:45 PM

Image folders problems
 
Good evening.
I am a new php programmer. :-D

I'm developing a website and i need some help.

I have an administrative area where i can do some tasks.

My problem is when i want to insert for example an image from a new product to show in the main page.

I want to put the images in a folder outside the admin area.

How can i do that?

Thanks ! ;-)

TlcAndres 12-16-2007 07:50 PM

well you can use the copy() function such would be an example

PHP Code:

 copy('root/admin/image.jpg','/root/imgs/newname.jpg'); 


ReSpawN 12-16-2007 08:14 PM

Or ofcourse through the upload function, put it in your image folder remotely.

You are in:
/root/admin/uploadform/
You want to PUT it into:
/root/images/uploads

your commandline in the index.php from uploadform will be;
../../images/uploads/

Good luck :)

Filipe Costa 12-16-2007 08:26 PM

But then i have a problem.
The path of the image is inserted in the database.

insert into product(name, path) ('asoldiasldki','../../images/image.png')

When i read, in the main page, i have the "../../images/" when i only want "images/"

How do i remove that?

Wildhoney 12-16-2007 09:00 PM

You could always go for a simple:

php Code:
str_replace('../', '', '../../images/');

Filipe Costa 12-26-2007 03:28 PM

It's working! :D

I used the str_replace().

Thank you all!!

Jelmer 12-26-2007 11:00 PM

nice, it might be easier to just store the filename, and then when you need to insert an image somewhere you can easily add the directory structure to the filename variable, it's just a bit more flexible I think.

xenon 12-27-2007 05:36 PM

Another (late) idea:

Code:

$image = 'images/' . basename( $image );


All times are GMT. The time now is 05:12 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0