Can't get php code to recognize folder

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mjtruksa
Forum Newbie
Posts: 4
Joined: Thu Jan 17, 2008 3:27 pm

Can't get php code to recognize folder

Post by mjtruksa »

I am currently trying to solve a problem with a dealer locator program I have installed on our company website it is produced by Your PHP Pro. All components have been successfully installed, however I am still getting an error that is as follows:
Unable to upload the file specified in Logo - temporary upload folder doesn't exist.
I have created a folder in our site named tmp,the folder is writable for me, for this purpose and here is the PHP code:

Code: Select all

 // Define locations for uploaded dealer logos
// Directories needs to be writable by the webserver.
// This directory is used for storing temp files during the file-uploading process.
define ("phpDealer_tmp_dir", $_SERVER['DOCUMENT_ROOT'] . 'http://xxxxxx.com/xxxxx/phpDealerLocator/tmp/');
I still cannot seem to get the program to recognize that this folder does exist so that I can start entering data any suggestions would be appreciated.
Thanks

~pickle | Please use [ syntax ="..." ] or [ code ] tags when posting code. Your post has been updated.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Can't get php code to recognize folder

Post by califdon »

mjtruksa wrote:

Code: Select all

define ("phpDealer_tmp_dir", $_SERVER['DOCUMENT_ROOT'] . 'http://xxxxxx.com/xxxxx/phpDealerLocator/tmp/');
I still cannot seem to get the program to recognize that this folder does exist so that I can start entering data any suggestions would be appreciated.
Thanks
That's because you are concatenating a fully qualified web address onto the end of the internal web server document root path. The period (.) in PHP is a string concatenation operator. You probably need to omit the http://xxxxxx.com/xxxx from that constant definition.
mjtruksa
Forum Newbie
Posts: 4
Joined: Thu Jan 17, 2008 3:27 pm

Re: Can't get php code to recognize folder

Post by mjtruksa »

Thanks for that it did help me to see the problem, I found the code had been changed and changed it back to its original format and now the folder is recognized.
However now I have another folder that is not recognized the code similar to the first post and is as follows:

// This directory is used to store the final dealer logos once they are uploaded.

Code: Select all

define ("phpDealer_img_dir", $_SERVER['DOCUMENT_ROOT'] . '/phpDealerLocator/images/');
The error is as follows:
Unable to upload the file specified in Logo - upload folder doesn't exist.

I am new to PHP and forums hope I have used code tags correctly.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Can't get php code to recognize folder

Post by John Cartwright »

mjtruksa wrote:Thanks for that it did help me to see the problem, I found the code had been changed and changed it back to its original format and now the folder is recognized.
However now I have another folder that is not recognized the code similar to the first post and is as follows:

// This directory is used to store the final dealer logos once they are uploaded.

Code: Select all

define ("phpDealer_img_dir", $_SERVER['DOCUMENT_ROOT'] . '/phpDealerLocator/images/');
The error is as follows:
Unable to upload the file specified in Logo - upload folder doesn't exist.

I am new to PHP and forums hope I have used code tags correctly.
My spider senses tell me the following will show the directory does not exist.. first, I think you need to double check the folder exists.

Code: Select all

 
echo 'Directory: "'. $_SERVER['DOCUMENT_ROOT'] . '/phpDealerLocator/images/" does '. file_exists($_SERVER['DOCUMENT_ROOT'] . '/phpDealerLocator/images/') ? 'not ' : '' . 'exist';
mjtruksa
Forum Newbie
Posts: 4
Joined: Thu Jan 17, 2008 3:27 pm

Re: Can't get php code to recognize folder

Post by mjtruksa »

The folder does exist: /******/gfxoops/phpDealerLocator/images
will I need to include the entire path to have the folder recognized?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Can't get php code to recognize folder

Post by John Cartwright »

mjtruksa wrote:The folder does exist: /******/gfxoops/phpDealerLocator/images
So that script you ran show the folder does infact exist?
will I need to include the entire path to have the folder recognized?
What do you mean? Are you referring to relative paths vs absolute paths?
mjtruksa
Forum Newbie
Posts: 4
Joined: Thu Jan 17, 2008 3:27 pm

Re: Can't get php code to recognize folder

Post by mjtruksa »

Just for an experiment I did try the entire path and received another error :

Parse error: parse error, unexpected T_STRING
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Can't get php code to recognize folder

Post by John Cartwright »

Code: Select all

$root = $_SERVER['DOCUMENT_ROOT'];
$exists = file_exists($root . '/phpDealerLocator/images/');
echo 'Directory: "'. $root . '/phpDealerLocator/images/" does '. (!$exists ? 'not ' : '') . 'exist';
Apologies, try this
Post Reply