file path problems with Zend Framework and fread()
I have a quick and hopefully simple question that I hope someone can help me with. I have a application that I am working on and I allow users to upload files. All files are loaded in to a directory with in the application folder of the project layout
/application
--/myuploadedfiles
/library
/public
However when I nee开发者_StackOverflowd to read them in using fread() I can't read the file as the path returned by the upload using Zend_File_Transfer_Http is
../application/myuploadedfiles/somefile.doc
Which when I try and read bombs out because fread can't seem to find it as I am getting this error
fread(): supplied argument is not a valid stream resource
What is the best way of getting the correct path to read the file so that I can process it??
I know that it is probably a simple bit of code but at the moment, I can't for the life of me figure it out.
Thanks.
Grant
Try taking that relative path you get back from Zend_File_Transfer
and passing it through the realpath()
function before trying to read the file contents.
精彩评论