inspire Posted September 25, 2007 Share Posted September 25, 2007 I have problem upload file. i am using php4.0.5. this upload file code work file in my friend pc which run php5.but in my pc, the page2.php display with empty page and the file not inserted into database. is that any setting need to be done in my php4.0.5 conf file? Pls help page1.php <html> <head> </head> <body bgcolor='#87CEFA'> <table> <tr> <td height="54"><b><font color="3300FF">Add Slide :</font></b> <input name="new_file" type="file" size="25" > <input type="Submit" value=" Upload" name="Submit"> <input type="hidden" name=MAX_FILE_SIZE; value="9000000"> <input type="hidden" name="ref" value="<? echo $id; ?>" ></td> </tr> </table> </form> </body> </html> page2.php <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $idt = $HTTP_POST_VARS['ref']; mysql_connect("localhost","trainee","123") or die ("Unable to connect server"); mysql_select_db("gddatab") or die("Unable connect database"); if(isset($_POST['Submit'])&& $_FILES['new_file']['size'] > 0) { $fileName = $_FILES['new_file']['name']; $tmpName = $_FILES['new_file']['tmp_name']; $fileSize =$_FILES['new_file']['size']; $fileType =$_FILES['new_file']['type']; $fileopen=fopen($tmpName,'r'); $content=fread($fileopen,fileSize($tmpName)); $content=addslashes($content); fclose($fileopen); if(!get_magic_quotes_gpc()) { $fileName=addslashes($fileName); } $sql="insert into ots_slide values ('','$fileName','$fileType','$fileSize','$content','$idt','jeeva','".date('y-m-d')."') "; $result=mysql_query($sql) or die ("Action Insert Fail"); echo "<script languange = 'Javascript'> alert('File $fileName uploaded'); location.href = 'page1.php'; </SCRIPT>"; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/70611-new-post-problem-with-file-upload/ Share on other sites More sharing options...
hemlata Posted September 25, 2007 Share Posted September 25, 2007 Hello, What posted values you are getting on page2.php?. Print variable $_POST[ on page2.php and see whether you are getting uploaded file's details or not. Regards, Quote Link to comment https://forums.phpfreaks.com/topic/70611-new-post-problem-with-file-upload/#findComment-354827 Share on other sites More sharing options...
localhost1 Posted September 25, 2007 Share Posted September 25, 2007 i think u have to define the form with enctype attribute like this <form id="frm" name="frm" method="post" action="new.php" enctype="multipart/form-data"> Quote Link to comment https://forums.phpfreaks.com/topic/70611-new-post-problem-with-file-upload/#findComment-354832 Share on other sites More sharing options...
HuggieBear Posted September 25, 2007 Share Posted September 25, 2007 i think u have to define the form with enctype attribute like this <form id="frm" name="frm" method="post" action="new.php" enctype="multipart/form-data"> You do indeed... Handling File Uploads Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/70611-new-post-problem-with-file-upload/#findComment-354833 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.