This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Can anyone help me with this simple question? I have Googled quite a bit but so far without success.
I have an HTML form which selects a file. I want to pass the full path of this file to another PHP/HTML script. It works fine in IE6 but not in Firefox. Specifically, all that gets passed in FF is the file name and not its path. Can anyone help?
You should not get the file path. You should get the file contents. This is only going to work when both the client and the server runs at the same machine. Imagine that I give you a file path of my local file system, are you able to access it through the network from your machine?
IE has the misbehaviour that it sends the complete path instead of only the filename. Firefox (and all other webbrowsers) is doing it right. Fo fix this IE misbehaviour and get only the filename, just trim everything away before the last slash.
In PHP you can get the file contents by $_FILES. Just google a decent PHP file upload tutorial for a how to.
I am actually trying to get the path of the directory within which the file exists. The called script then cycles through all the files in that directory and processes them. Specifically, the script resizes (downsizes) all the jpg images in the directory. And yes, it so happens that I am running both the server and the client on the same PC.
FYI my environment is:
. Dell Core 2 Duo PC
. Windows XP Pro SP3
. PHP version 5.2.6
. IIS version 5.1
. MySQL version 5.0.51b-community-nt
. Dreamweaver MX2004 version 7 as the "text editor"
. Internet Explorer version 6.0.2900
. Adobe AIR runtime version 188.8.131.5220
. Aptana Studio version 184.108.40.206
All running on the Dell PC - i.e., all executions are via 'localhost'
When I was developing this application, I was advised that the above technique was the only way to select a directory (on the client) in HTML/PHP without hard-coding it.
While I'm at it, does anyone know how to resize images using JS/AIR? The PHP code to do this is quite neat and I found it via Googling on the 'net.
Again, thanks for your thoughts/advice so far.
Cheers from Oz,
Joined: Jan 24, 2009
One further point, I need to actually downsize the size of the jpg files, not just their appearance on a screen. They later get uploaded to an image server.