Page 1 of 1
Can't get php code to recognize folder
Posted: Thu Jan 17, 2008 3:43 pm
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.
Re: Can't get php code to recognize folder
Posted: Thu Jan 17, 2008 9:03 pm
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.
Re: Can't get php code to recognize folder
Posted: Fri Jan 18, 2008 12:03 pm
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.
Re: Can't get php code to recognize folder
Posted: Fri Jan 18, 2008 12:15 pm
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';
Re: Can't get php code to recognize folder
Posted: Fri Jan 18, 2008 12:40 pm
by mjtruksa
The folder does exist: /******/gfxoops/phpDealerLocator/images
will I need to include the entire path to have the folder recognized?
Re: Can't get php code to recognize folder
Posted: Fri Jan 18, 2008 12:46 pm
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?
Re: Can't get php code to recognize folder
Posted: Fri Jan 18, 2008 12:47 pm
by mjtruksa
Just for an experiment I did try the entire path and received another error :
Parse error: parse error, unexpected T_STRING
Re: Can't get php code to recognize folder
Posted: Fri Jan 18, 2008 12:53 pm
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