Log in

View Full Version : Save a file to server



vyenpakakapaka
11-08-2009, 05:36 AM
Specifically a PNG (or, heck, any kinda image) file. Here's the situation...

Using an online code example as a base, I've tweaked and made a simple PHP app that takes your latest tweet and puts it onto a .PNG image: http://quellman.info/ts/vk.php

The problem is that little .php at the end. Some of the forums I frequent don't parse the .php as the PNG file it's creating. It sees I typed in .PHP and just spits out the BB code instead of the image file.

I know I'm looking for server-side for this, and I'd have to have the applet run often enough to catch my new tweets, but is there any way I can have the PHP applet create the .PNG file on the server, so I can point the forum siggies to a .PNG instead of a .PHP? Is it even gonna be worth the effort? I'm no PHP or coding wizard, but I took a few college-level courses. If someone could even point me to the right library, function, whatever, I'm sure I can muddle through it. I just haven't been able to find said library, function, and/or whatever.

also, I've already tried renaming my applet.php to applet.png. No dice. =P

thetestingsite
11-08-2009, 06:08 AM
We would need to see your code to be able to help you further, but what you could do is basically save the image that is being created by your php script, then add something like this everytime the file is run:



if (file_exists('image.png')) {
unlink('image.png');
//rest of save file code here
}


The other option is to use .htaccess to point a png file to the php script. An example of this would be:



Options +FollowSymlinks
RewriteEngine on
RewriteRule image.png /yourscript.php


Hope this helps.

fg123
11-08-2009, 09:09 PM
I guess you should save the file to the server first, then link to that file.:
http://www.tizag.com/phpT/fileupload.php