Reputation: 1
I'm unable to set path in function of setDestination()
to upload a file in zend framework.
My file is successfully uploaded, when I use path like:
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination("C:/");
but actually I want to upload a file in directory say upload_folder
which is in public directory in zend framework. I have tried my codes as:
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination($this->view->baseUrl()."/upload_folder/");
but the file is not uploaded in the above path directory.
Can anyone help me? How to set path for file upload in Project_Directory/public/upload_folder
?
Upvotes: 0
Views: 716
Reputation: 25745
set the upload path using APPLICATION_PATH
constant
setDestination(APPLICATION_PATH.'/../public/upload_folder/')
Upvotes: 1
Reputation: 3008
setDestination
would require a filesystem path, hence why C:/
works and using baseUrl
doesn't.
$this->view->baseUrl
would be http://yourserver.com
(that's a URL, not a filesystem path).
If you've setup your Zend Framework like most of the examples, you should have an APPLICATION_PATH
variable set to e.g. C:/project/application
(you would also have C:/project/public
for example).
If you do have APPLICATION_PATH
(just echo it to see where it goes), then you can use setDestination(APPLICATION_PATH.'/../public/upload_folder/');
Upvotes: 3