standard-adressing vs. web-addressing in PHP

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Forum rules
Post Reply
User avatar
FredFlinstone
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Jun 13, 2006 3:05 pm
Location: Albershausen, Germany
Contact:

standard-adressing vs. web-addressing in PHP

Post by FredFlinstone » Mon Feb 18, 2008 4:02 pm

Hi friend,
sorry for my little bit confused topic title (standard-adressing vs. web-addressing in PHP).

My problem is (maybe) very simply:

I have some code for upload file to some Joomla directories on server:

$uploaddir=$conf_ImageUploadDirectory;
/* value for $conf_ImageUploadDirectory is defined in config file:
"C:\\WebServer\\Neptunius\\images\\UserPhotos\\"
*/

for upload (and for next rename of file) I use this style of addressing (absolute "windows" location: C:\\WebServer\\Neptunius\\images\\UserPhotos\\ ),
it's right in my localhost, but problem is on my webhosting. I don't know "absolute location" of directories. And would be better using some "web-style" addressing (eg. http://myweb/images/UserPhotos/, or: ../images/UserPhotos/ or something similar.

How can I use it then in PHP functions: rename(..), move_uploaded_file(..), unlink(..) ???
These functions are working with "absolute addressing", or are not?

thanks for help
FF

User avatar
Rogue4ngel
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 199
Joined: Sun Nov 26, 2006 10:46 pm
Location: New York

Re: standard-adressing vs. web-addressing in PHP

Post by Rogue4ngel » Mon Feb 18, 2008 7:25 pm

Depending on your web site hosting, there should be a listing for your absolute address. If you can't find it, I'd contact your web host and ask them to give you the absolute address. It would make your life a lot easier than trying to try to 'trick 'the functions to work differently.
If you're not a part of the solution, you're a part of the problem.

User avatar
FredFlinstone
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Jun 13, 2006 3:05 pm
Location: Albershausen, Germany
Contact:

Re: standard-adressing vs. web-addressing in PHP

Post by FredFlinstone » Tue Feb 19, 2008 10:31 am

Rogue4ngel wrote:Depending on your web site hosting, there should be a listing for your absolute address. If you can't find it, I'd contact your web host and ask them to give you the absolute address. It would make your life a lot easier than trying to try to 'trick 'the functions to work differently.


So it is the simplest solution, but ask to administrator for this information may be ...
Doesn't exist some tricky solution for that problem?
How can I upload (and delete) some files to my web (if it located on web hosting), if I don't know this info?

thanks

User avatar
Rogue4ngel
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 199
Joined: Sun Nov 26, 2006 10:46 pm
Location: New York

Re: standard-adressing vs. web-addressing in PHP

Post by Rogue4ngel » Tue Feb 19, 2008 1:11 pm

I'm not exactly sure what you mean. Is it that you can't get the web site information from the host, or your just not sure how to do it?
If you're not a part of the solution, you're a part of the problem.

User avatar
FredFlinstone
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Jun 13, 2006 3:05 pm
Location: Albershausen, Germany
Contact:

Re: standard-adressing vs. web-addressing in PHP

Post by FredFlinstone » Tue Feb 19, 2008 2:54 pm

Rogue4ngel wrote:I'm not exactly sure what you mean. Is it that you can't get the web site information from the host, or your just not sure how to do it?


Of course, I ask my web-host administrator for these infomation, but inspite of I would want to know other solution (in my opinion - more intelligent).

FF

User avatar
Rogue4ngel
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 199
Joined: Sun Nov 26, 2006 10:46 pm
Location: New York

Re: standard-adressing vs. web-addressing in PHP

Post by Rogue4ngel » Tue Feb 19, 2008 4:21 pm

I have not seen any documentation that would allow you to use relative positioning for the functions you have mentioned. As far as I know, they require absolute positioning.
If you're not a part of the solution, you're a part of the problem.

User avatar
FredFlinstone
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Jun 13, 2006 3:05 pm
Location: Albershausen, Germany
Contact:

Re: standard-adressing vs. web-addressing in PHP

Post by FredFlinstone » Fri Feb 22, 2008 7:24 am

Rogue4ngel wrote:I have not seen any documentation that would allow you to use relative positioning for the functions you have mentioned. As far as I know, they require absolute positioning.
I asked to admin on my web-hosting (btw. it is SiteGround) for info about absolute path. There is:
absolute location is: /home/blabla/
and my web side is located in: /home/blabla/public_html/

OK, the same information I find in back-end my Joomla installation in "Global configuration -> Server":
Absolute path: /home/blabla/public_html
(opposite on my local installation there is: C:/WebServer/Virtual/Neptun)
and Live site parameter: http://blabla.net (opposite on my local: http://localhost/neptun)

And for upload function in Joomla component is set constant in "config.component.php" file (on my local installation) in following way: $conf_ImageUploadDirectory="C:\\WebServer\\Virtual\\Neptun\\images\\UserPhotos\\";

Similarly I try set this parameter in "config.component.php" file on my web-hosting to value:
$conf_ImageUploadDirectory="/home/inetyou/public_html/images/UserPhotos";

but it is not running.
PS: directory "images/UserPhotos" exists and is set to write for all.

Do you have some idea?

thanks, FF

User avatar
FredFlinstone
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Tue Jun 13, 2006 3:05 pm
Location: Albershausen, Germany
Contact:

Re: standard-adressing vs. web-addressing in PHP

Post by FredFlinstone » Mon Mar 03, 2008 10:36 am

The problem is resolved.

in config.mycomponent.php is defined:

$conf_ImageUploadDirectory="/images/UserPhotos/";
...

and in scripts of my components is used:

$uploaddir=mosPathName($mosConfig_absolute_path.$conf_ImageUploadDirectory);
...
/* and in process for upload file: */
$uploadfile=$uploaddir.$_FILES['userfile']['name'];
if (move_uploaded_file($_FILES['userfile']['tmp_name'],$uploadfile)) {
...
}

thank for all for ideas

User avatar
Rogue4ngel
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 199
Joined: Sun Nov 26, 2006 10:46 pm
Location: New York

Re: standard-adressing vs. web-addressing in PHP

Post by Rogue4ngel » Mon Mar 03, 2008 9:17 pm

Excellent... glad you were able to get what you needed.
If you're not a part of the solution, you're a part of the problem.


Post Reply