views:

47

answers:

1

How can I specify filepath to imagepng function? It always seems to create the file in "/public" folder when used in an MVC Zend Framework and even when an explicit filepath is supplied. Is it because of the rewrite rules I have? My .htaccess rewrite rules are as under:

FileETag none
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 10 years"
ExpiresByType image/gif "access plus 10 years"
ExpiresByType image/jpeg "access plus 10 years"
ExpiresByType image/png "access plus 10 years"
ExpiresByType text/css "access plus 10 years"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType text/javascript "access plus 10 years"
ExpiresByType application/x-unknown-content-type "access plus 10 years"
ExpiresByType application/x-javascript "access plus 10 years"
</IfModule>

ExpiresActive On
ExpiresDefault A604800
ExpiresByType image/x-icon A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/css A2592000
ExpiresByType text/html A300
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
ExpiresActive Off
</FilesMatch>


# compress all text & html:
AddOutputFilterByType DEFLATE text/html text/plain text/xml

# Or, compress certain file types by extension:
<Files *.html>
SetOutputFilter DEFLATE
</Files>

RewriteEngine   on
# The leading %{DOCUMENT_ROOT} is necessary when used in VirtualHost context
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -s [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -l [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]

RewriteRule ^.*$ index.php [NC,L]
+1  A: 

EDIT: Upon Closer examination it is your rewrite rules... Why are you using %{DOCUMENT_ROOT}? You shouldnt need to mention it in your rewrite stack. That should be mapped directly in you vhost config. If you had to do that to get Zend to work something is either wrong in your app config or in your vhost. If youre hosting out of a sub dir of the docroot set the baseurl on the front controller.


What is the path youre trying to write to? You should use the full filesystem path to where you want the image written for example:

imagepng($image, APPLICATION_PATH.'/public/images/generated_image.png');

You should probably use other dynamic tools to build that path in case you ever change the actual directory for public but that was jsut a simple example :-)

If you use a relative path the path will always be relative to public because thats the dir index.php is in and it processes everything. The URL in the browser doesnt nessecarily reflect the path youre operating out of because of the standard rewrite rules/routing.

prodigitalson
The funny part is it is adding "/public/" as a prefix by default. So, even if I specify APPLICATION_PATH.'/public/images/generated_image.png', it appears to write it as '/public/'.APPLICATION_PATH.'/public/images/generated_image.png'How can I get rid of /public prefix?
Vincent
See my edit above.
prodigitalson