|
-
Apr 24th, 2002, 06:23 PM
#1
Thread Starter
Frenzied Member
PHP File Uploading
When I run this code, I get an error saying that userfile_size is undefined. According to the book I am reading, this variable should automaticly be defined,a nd hold the size of the file uploaded. Am I missing something?
PHP Code:
<html>
<head>
<title>Uploading</title>
</head>
<body>
<h1>Uploading file...</h1>
<?php
if ($userfile=="none")
{
echo "Problem: no file uploaded";
exit;
}
if ($userfile_size==0)
{
echo "Problem: uploaded file is zero length";
exit;
}
if ($userfile_type != "text/plain")
{
echo "Problem: file is not plain text";
exit;
}
$upfile = "c:\\".$userfile_name;
if (!copy($userfile, $upfile))
{
echo "Problem: Could not move file into directory";
exit;
}
echo "File uploaded successfully<br><br>";
?>
</body></html>
-
Apr 24th, 2002, 09:18 PM
#2
Stuck in the 80s
Re: PHP File Uploading
Originally posted by blindlizard
When I run this code, I get an error saying that userfile_size is undefined. According to the book I am reading, this variable should automaticly be defined,a nd hold the size of the file uploaded. Am I missing something?
I think in order to see what's going on, we'd have to see more. How is the file being selected, where are these variables being created at. Unless I'm missing something, this code shouldn't do much of anything at all.
-
Apr 24th, 2002, 10:49 PM
#3
in your form you have to have an hidden input holding the file size.
<input type="hidden" name="userfile_size" value="$userfile_size">
-
Apr 25th, 2002, 11:11 AM
#4
Thread Starter
Frenzied Member
Here is the page sending the file
PHP Code:
<HTML>
<HEAD>
</HEAD>
<BODY>
<form enctype="multipart/form-date" action="test.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000">
<INPUT type="file" name="userfile">
<INPUT type="submit" value="Submit" id=submit1 name=submit1>
</form>
</BODY>
</HTML>
-
Apr 25th, 2002, 11:45 AM
#5
Black Cat
multipart/form-date
is that a typo here or in the real page?
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Apr 25th, 2002, 12:00 PM
#6
Thread Starter
Frenzied Member
Oh my God!!! that has to be it......Thanks
-
Apr 25th, 2002, 12:10 PM
#7
Thread Starter
Frenzied Member
That worked, thank you. I knew it should not be that difficult to upload in PHP!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|