|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-11-08 18:49 UTC] sniper@php.net
[2000-12-07 11:33 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 08:00:02 2025 UTC |
<html> <head> <title>Upload files here:</title> </head> <body> <FORM ENCTYPE="multipart/form-data" ACTION="<?echo $PHP_SELF ?>" METHOD=POST> Send this file: <br> <input type="hidden" name="MAX_FILE_SIZE" value="1000000"> <INPUT NAME="userfile" TYPE="file"> <br><INPUT TYPE="submit" name="upload" VALUE="Send File"> </FORM> <? if(isset($userfile)) { if (($userfile_type == "image/gif" ) or ($userfile_type == "image/jpeg") or ($userfile_type == "image/jpg") or ($userfile_type == "image/pjpeg")) { $hostname = "10.56.33.133"; // host $username = "root"; // user $password = "root"; // password $usertable = "bilder"; // tablename $dbName = "pix"; // dbname //connect to database $db = MYSQL_CONNECT($hostname, $username, $password) OR DIE( "Unable to connect to database"); mysql_select_db( $dbName, $db) or die( "Unable to select database"); $fp = fopen($userfile, "r"); $imagedata = addslashes(fread( $fp, filesize($userfile))); fclose($fp); echo filesize($userfile); echo "||"; echo strlen($imagedata); $insert = "insert into $usertable(data, mime) values('$imagedata', '$userfile_type')"; $result = MYSQL_QUERY($insert, $db); $idnum = mysql_insert_id(); echo "<img src=\"get.php?id=$idnum\"><br>"; mysql_close($db); } } ?> <!-- Problem is reproduceable. PHP isn't able to upload files. You get a filesize of xxx bytes but fread didn't appears to read the whole file. Also the script works on apache and php 4.0.1 pl2 fine. !--> </body> </html>