TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-16-2007, 07:45 PM   #1 (permalink)
The Wanderer
 
Filipe Costa's Avatar
 
Join Date: Sep 2007
Location: Viseu, Portugal
Posts: 5
Thanks: 1
Filipe Costa is on a distinguished road
Default Image folders problems

Good evening.
I am a new php programmer.

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 !
Filipe Costa is offline  
Reply With Quote
Old 12-16-2007, 07:50 PM   #2 (permalink)
The Addict
 
Join Date: Nov 2007
Posts: 264
Thanks: 2
TlcAndres is on a distinguished road
Default

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

PHP Code:
 copy('root/admin/image.jpg','/root/imgs/newname.jpg'); 
TlcAndres is offline  
Reply With Quote
Old 12-16-2007, 08:14 PM   #3 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default

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 :)
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 12-16-2007, 08:26 PM   #4 (permalink)
The Wanderer
 
Filipe Costa's Avatar
 
Join Date: Sep 2007
Location: Viseu, Portugal
Posts: 5
Thanks: 1
Filipe Costa is on a distinguished road
Default

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?
Filipe Costa is offline  
Reply With Quote
Old 12-16-2007, 09:00 PM   #5 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

You could always go for a simple:

php Code:
str_replace('../', '', '../../images/');
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 12-26-2007, 03:28 PM   #6 (permalink)
The Wanderer
 
Filipe Costa's Avatar
 
Join Date: Sep 2007
Location: Viseu, Portugal
Posts: 5
Thanks: 1
Filipe Costa is on a distinguished road
Default

It's working! :D

I used the str_replace().

Thank you all!!
Filipe Costa is offline  
Reply With Quote
Old 12-26-2007, 11:00 PM   #7 (permalink)
The Wanderer
 
Join Date: Dec 2007
Location: The Netherlands
Posts: 13
Thanks: 3
Jelmer is on a distinguished road
Default

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.
Jelmer is offline  
Reply With Quote
Old 12-27-2007, 05:36 PM   #8 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Another (late) idea:

Code:
$image = 'images/' . basename( $image );
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:55 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design