standard-adressing vs. web-addressing in PHP
Moderators: tjay, seadap, Rogue4ngel, matthewhayashida
Forum rules
- FredFlinstone
- Joomla! Apprentice
- Posts: 8
- Joined: Tue Jun 13, 2006 3:05 pm
- Location: Albershausen, Germany
- Contact:
standard-adressing vs. web-addressing in PHP
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
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
- Rogue4ngel
- Joomla! Enthusiast
- Posts: 199
- Joined: Sun Nov 26, 2006 10:46 pm
- Location: New York
Re: standard-adressing vs. web-addressing in PHP
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.
- FredFlinstone
- Joomla! Apprentice
- Posts: 8
- Joined: Tue Jun 13, 2006 3:05 pm
- Location: Albershausen, Germany
- Contact:
Re: standard-adressing vs. web-addressing in PHP
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
- Rogue4ngel
- Joomla! Enthusiast
- Posts: 199
- Joined: Sun Nov 26, 2006 10:46 pm
- Location: New York
Re: standard-adressing vs. web-addressing in PHP
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.
- FredFlinstone
- Joomla! Apprentice
- Posts: 8
- Joined: Tue Jun 13, 2006 3:05 pm
- Location: Albershausen, Germany
- Contact:
Re: standard-adressing vs. web-addressing in PHP
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
- Rogue4ngel
- Joomla! Enthusiast
- Posts: 199
- Joined: Sun Nov 26, 2006 10:46 pm
- Location: New York
Re: standard-adressing vs. web-addressing in PHP
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.
- FredFlinstone
- Joomla! Apprentice
- Posts: 8
- Joined: Tue Jun 13, 2006 3:05 pm
- Location: Albershausen, Germany
- Contact:
Re: standard-adressing vs. web-addressing in PHP
I asked to admin on my web-hosting (btw. it is SiteGround) for info about absolute path. There is: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.
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
- FredFlinstone
- Joomla! Apprentice
- Posts: 8
- Joined: Tue Jun 13, 2006 3:05 pm
- Location: Albershausen, Germany
- Contact:
Re: standard-adressing vs. web-addressing in PHP
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
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
- Rogue4ngel
- Joomla! Enthusiast
- Posts: 199
- Joined: Sun Nov 26, 2006 10:46 pm
- Location: New York
Re: standard-adressing vs. web-addressing in PHP
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.