Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old Jul 20th, 2004, 9:49 AM   #11
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,453
Rep Power: 7 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Quote:
You can never know too many ways to do somthing.
I agree.

Here was my approach:


<?php

$path = "C:\\Program Files\\Apache Group\\Apache2\\htdocs\\data\\upload\\";
$max_size = 2000000;

if (!isset($HTTP_POST_FILES['userfile'])) exit;

if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {

if ($HTTP_POST_FILES['userfile']['size']>$max_size) { echo "The file is too big
\n"; exit; }

if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) { echo "The file already exists
\n"; exit; }

$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .
$HTTP_POST_FILES['userfile']['name']);
if (!$res) { echo "upload failed!
\n"; exit; } else { echo "upload sucessful
\n"; }

echo "File Name: ".$HTTP_POST_FILES['userfile']['name']."
\n";
echo "File Size: ".$HTTP_POST_FILES['userfile']['size']." bytes
\n";
echo "File Type: ".$HTTP_POST_FILES['userfile']['type']."
\n";
} else { echo "Wrong file type
\n"; exit; }

?>
__________________
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 20th, 2004, 1:12 PM   #12
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
Cool, thanks for the code. Yours is for a windows box though. I might have just been running into file permissions with my code. It's a little "easyer" to do stuff like this on windows box, since all applications have root rights. Anyways, 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 20th, 2004, 6:21 PM   #13
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,453
Rep Power: 7 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
You're welcome. File permissions are definitely a pain in unix related environments. Although I had to alter file permissions as well, because of the way I have my security policy set up on my Windows box. A few minor changes and the same script would be ready to roll on a linux box.
__________________
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
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 6:40 AM.

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