inspire Posted September 25, 2007 Share Posted September 25, 2007 When the file upload button(Submit) clicked , file not saved and new-slideinsert.php display and its not directed to new-course.php. i use uploadtemp folder at php to store the temp file Anyone can help me.... ??? <? session_start(); /* $name=$_SESSION['u_name']; if ($_SESSION['u_name']=='') { echo "<script languange = 'Javascript'> alert('Please Login to access the page'); location.href = 'index.php'; </SCRIPT>"; }*/ ?> <?php echo $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']['tmp_siz']; $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 = 'new-course.php'; </SCRIPT>"; } Quote Link to comment Share on other sites More sharing options...
Aeglos Posted September 25, 2007 Share Posted September 25, 2007 You are not saving the file anywhere. You need to use move_uploaded_file() before your fopen() block, like: <?php move_uploaded_file($_FILES['new_file']['tmp_name'], $destination_file); ?> Where $destination_file contains the destination folder and filename where you want to save your file. for example: "../images/chuck_norris.jpg". EDIT: Blargh, I just noticed that it might not be what you need since you seem to want to only extract the contents of a posted file instead of saving the actual file. I just got discombobulated... *dies* Quote Link to comment Share on other sites More sharing options...
inspire Posted September 25, 2007 Author Share Posted September 25, 2007 When the file upload button(Submit) clicked , file not saved and new-slideinsert.php display and its not directed to new-course.php. i use uploadtemp folder at php to store the temp file Anyone can help me.... ??? <? session_start(); /* $name=$_SESSION['u_name']; if ($_SESSION['u_name']=='') { echo "<script languange = 'Javascript'> alert('Please Login to access the page'); location.href = 'index.php'; </SCRIPT>"; }*/ ?> <?php echo $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']['tmp_siz']; $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 = 'new-course.php'; </SCRIPT>"; } Quote Link to comment Share on other sites More sharing options...
AdRock Posted September 25, 2007 Share Posted September 25, 2007 Has file permissions been set on the folder you are uploading to? If they haven't, you won't be able to upload Quote Link to comment 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.