Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   PHP v4.3.7, Apache 2 and Slackware 9.1 (http://www.programmingforums.org/showthread.php?t=158)

Pizentios Jul 13th, 2004 12:51 PM

I have been trying to get a script to work that lets the user upload a picture through an html form. Coding it is the easy part.....for some reason, that i can't explain why file uploads (through an html form) won't work on my server. I tryed fooling around with the php.ini file and httpd.conf file. Nothing i've tryed has seemed to work. I have noticed one thing: The var $HTTP_POST_FILES and $_FILES (there really the same thing.) arn't getting set. I am thinking that the file isn't getting uploaded to the server tmp dir. here's the code that i am using:

:


 $file = $_FILES['testfile']['tmp_name'];
 $path = "/usr/local/web/";
 $dest = "";
 $size = getimagesize($file);
 echo $file . "<-- The File On The System!<br>";
 echo $size . "<-- The Size!<br>";
 switch ($size)
 {
 * * * * * *case 0:
 * * * * * * * * * * * *echo "Image is unknowen";
 * * * * * * * * * * * *break;
 * * * * * * *case 1:
 * * * * * * * * * * * *echo "Images is a GIF";
 * * * * * * * * * * * *$dest = $path.uniqid('img').'gif';
 * * * * * * * * * * * * *break;
 * * * * * * *case 2:
 * * * * * * * * * * * *echo "Image is a JPG";
 * * * * * * * * * * * *$dest = $path.uniqid('img').'gif';
 * * * * * * * * * * * *break;
 * * * * * * *case 3:
 * * * * * * * * * * * * *echo "Image is a PNG";
 * * * * * * * * * * * * *$dest = $path.uniqid('img').'gif';
 * ** * * * * * * * * * * *break;
 * }
* *if ($dest != "")
* *{
* * * * * * * *if (move_uploaded_file($file, $dest))
 * * * * * * *{
    * * * * * * * *echo "File moved.";
 * * * * * * *}
 * * * * * * *else
 * * * * * * *{
 * * * * * * * * * * * *echo "Could not move the file.";
 * * * * * * *}
* * *}


Anyways, the part where i echo the file names and shit at the top only outputs the text that i apended to it, nothing else. Anyways, does anybody here have a clue to what's going on? I think the whole problem is to do with apache and slackware, but i am not sure. Thanks for the help in advance.

The Hack Jul 14th, 2004 10:01 AM

For Apache, I am not sure if it will work, but in AddType, did you add the PHP?

If not, add the foolwing code:
Quote:

AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .phtml .php .php3 .php4
AddType application/x-httpd-php-source .phps

ScriptAlias /php/ "c:/php?"
Action application/x-httpd-php "/php/php.exe"

Add the part in the red

Pizentios Jul 14th, 2004 10:08 AM

Thanks for the reply. Yeah i have the AddType all setup...other wise my scripts wouldn't even run. The stuff you have at the bottom of your quote is for windows....not Linux. Unless there's equlivant directives for linux, there not really that much help. I will look around for their linux counter parts.
Thanks again.

-Pizentios

Pizentios Jul 19th, 2004 9:33 AM

I figured it out. You seem to need to use fopen to open the file when it's in the system temp file in order to access it, makes sence i guess. Thanks for you're help though.

Infinite Recursion Jul 19th, 2004 2:28 PM

Ahhhh :( Answered before I got to it. Glad that you got it working!

Pizentios Jul 19th, 2004 2:40 PM

Did you have the same answer??

-Pizentios

Infinite Recursion Jul 19th, 2004 8:56 PM

Nah. I was going to send you an easier to follow upload script.

kurifu Jul 19th, 2004 9:33 PM

Quote:

Originally posted by Pizentios@Jul 19 2004, 01:33 PM
I figured it out. You seem to need to use fopen to open the file when it's in the system temp file in order to access it, makes sence i guess. Thanks for you're help though.
You have needed to do this since PHP4, there were several security issues with the old PHP3 method of handling uploaded files.

Pizentios Jul 20th, 2004 10:10 AM

Quote:

You have needed to do this since PHP4, there were several security issues with the old PHP3 method of handling uploaded files.
hmmm, that's odd, because i was getting my excamples off teh web docs....oh well.

-Pizentios

Pizentios Jul 20th, 2004 10:11 AM

Quote:

Nah. I was going to send you an easier to follow upload script.
You Should post it here. Just to see the difference. You can never know too many ways to do somthing.


-Pizentios


All times are GMT -5. The time now is 4:26 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC