Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 13th, 2004, 11:51 AM   #1
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
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.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Jul 14th, 2004, 9:01 AM   #2
The Hack
Newbie
 
Join Date: Jul 2004
Posts: 7
Rep Power: 0 The Hack is on a distinguished road
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
__________________
Currently Learning: <span style='color:red'>PHP, Visual Basic, C++</span>
I have learned: <span style='color:green'>HTML</span>

The Hack- coming to theatres near you...
The Hack is offline   Reply With Quote
Old Jul 14th, 2004, 9:08 AM   #3
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
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
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Jul 19th, 2004, 8:33 AM   #4
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
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.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Jul 19th, 2004, 1:28 PM   #5
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,466
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Ahhhh Answered before I got to it. Glad that you got it working!
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Jul 19th, 2004, 1:40 PM   #6
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
Did you have the same answer??

-Pizentios
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Jul 19th, 2004, 7:56 PM   #7
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,466
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Nah. I was going to send you an easier to follow upload script.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Jul 19th, 2004, 8:33 PM   #8
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
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.
__________________
Clifford Matthew Roche &lt;geek@cliffordroche.com&gt;
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Jul 20th, 2004, 9:10 AM   #9
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
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
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Old Jul 20th, 2004, 9:11 AM   #10
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
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
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:03 PM.

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