Try using the $_files['photo']['error'] variable to see if the file is acutaly being uploaded correctly. I had the same problem on Windows XP, but i discovered the file was only half-uploaded using this.
- Daniel "TheHeadSage" Spain Founder of Voidsoft. [EMAIL PROTECTED] ~ Manga Sketchbook, the best Manga Scanlation group! ~ On 8 Jan 2003 at 21:35, Submission.org.ru Team wrote: > Hello php-general, > I'm trying to figure out why I can't upload any file in php. > > Form code > ======== > <form name="photoform" action="photos.php" method="post" >enctype="multipart/form-data"> > <input type="hidden" name="MAX_FILE_SIZE" value="40960"> > <table border="0" cellspacing="0" cellpadding="2"> > <tr> > <td colspan="2" class="emphasis">Use this form to upload your new photographs. Note: >only JPEG (.jpg) and PNG (.png) files allowed. Maximimum allowed file size is >40KB.</td> > </tr> > <tr> > <td>Photograph: </td> > <td><input type="file" name="photo" /></td> > </tr> > <tr> > <td>Description: </td> > <td> > <textarea name="photodesc" rows="3" cols="30"><?php echo $_POST["photodesc"] >?></textarea> > </td> > </tr> > <tr> > <td colspan="2" align="center"><input type="submit" name="fileupload" value="Upload" >/></td> > </tr> > </table> > </form> > > PHP code > ======= > <?php > if ($_POST["fileupload"] == "Upload") { > $errormsg = ""; > $photospath ="/home/freeman/upload"; > $filename = $_FILES['photo']['name']; > $filetype = $_FILES['photo']['type']; > $filesize = (int) $_FILES['photo']['size']; > > if ($filetype == "image/jpeg" || $filetype == "image/pjpeg" || $filetype == >"image/png" || $filetype == "image/x-png") { > if ($filesize < 40960 && $filesize > 0) { > $storename = $uniqueid = md5 (uniqid (rand)); > if ($filetype == "image/jpeg" || $filetype == "image/pjpeg") $storename .= ".jpg"; > if ($filename == "image/png" || $filetype == "image/x-png") $storename .= ".png"; > $desc = $_POST["photodesc"]; > > // Store the file in the photos folder and add record to database > if (is_uploaded_file ($_FILES['photo']['tmp_name'])) { > if (!@move_uploaded_file ($_FILES['photo']['tmp_name'], $photospath.$storename)) { > $errormsg .= " Problem uploading the file. Please try again. If the problem persists >please email [EMAIL PROTECTED] to report the error."; > } else { > @chmod ($photospath.$storename, 0644); > $sql = "INSERT INTO hcs_photos (clientID,photoName,photoTitle,uploadTimeStamp) >VALUES ('". $_SESSION["clientID"] ."','$storename','$desc','$timestamp')"; > $db->Query ($sql, $conn); > } > > } else { > $errormsg .= "Possible file upload attack. Filename: ". $_FILES['photo']['name']; > } > } else { > $errormsg .= "Invalid file size. Maximum of 40KB allowed"; > } > } else { > $errormsg .= "Invalid file type. Only JPEG and PNG files allowed"; > } > if (strlen ($errormsg) < 5) { > header ("Location: ". $baseurl ."photos.php"); > } > } > ?> > > When I upload a file I get > $filesize equal to 0. > > In my php.ini i got the following section: > ; Whether to allow HTTP file uploads. > file_uploads = On > > ; Temporary directory for HTTP uploaded files (will use system default if not > ; specified). > upload_tmp_dir = "/tmp" > > ; Maximum allowed size for uploaded files. > upload_max_filesize = 2M > > > Please help. PHP even does not create a temp file in a temp directory. > /tmp got permission 777 > > I'm running Apache 2.0.43 and RedHat Linux > > -- > Best regards, > Submission.org.ru mailto:[EMAIL PROTECTED] > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php