Brendan Posted February 9, 2007 Share Posted February 9, 2007 Hello all, i'm upgrading my servers from php4 to php5, and have an upload script left unworking. Rather than upload a file, it just refreshes the page and clears the form after it reads the file. <?php include("../login.php"); ?> <html><head> <script language="javascript" src="../functions.js"></script> <style type="text/css"> html, body, td { background-color: #364962; color: #ffffff; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: bold; } INPUT, TEXTAREA { background-color: #ffffff; border-color: #000000; border-style: solid; border-width: 1px; color: #000000; padding:2px; height:18px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: normal; } SELECT { background-color: #ffffff; border:1px solid black; color: #000000; height:18px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 8pt; font-weight: normal; } OPTION { background-color: #ffffff; border:0px solid black; color: #000000; } .Radio { background-color: #ffffff; border-width: 0px; color: #000000; } </style> <?php require("../functions.php"); $filename=$_POST["filename"]; $overwrite!="ON"; $description=$_POST["description"]; $submit=$_POST["submit"]; $userfile=$_FILES['upload']; $filename=stripslashes($filename); $description=stripslashes($description); $dirval='/home/user/directory/files/'; $sql=mysql_query("select * from users where id='$id_iq'"); if(!empty($sql)){ $row=mysql_fetch_array($sql); $username=$row["username"]; $level=$row["level"]; } $sqlnum=mysql_query("select * from example where username='$username'"); $sqlnum= mysql_num_rows($sqlnum); if ($level = 1) { $maxfiles = "5"; } else if ($level=2) { $maxfiles = "10"; } $maxsize = "7340032"; if ($submit) { if ($sqlnum < $maxfiles) { if (!empty($filename)) { if($submit && $userfile && $userfile['size']!=0) { //If a file is uploaded... $filename = $id_iq.'_'.$userfile['name']; $filename_temp = explode(" ", $filename); $filename = implode("_", $filename_temp); $size = $userfile['size']; $error = $userfile['error']; if ($size<=$maxsize) { if($error!=0){ //If an error occured then... showerror('Error'); } if (file_exists($dirval.$filename)&&$overwrite!="ON") { //Check if the file already exists... showerror('File already exists'); //Or display error } else { $ext = substr($filename, strrpos($filename, '.') + 1); $ext = strtolower($ext); if($ext=="doc"){ $correctfile=true; $correctformat=true; } else { $correctfile=false; $correctformat=false; } if ($correctfile) { $uploaded=move_uploaded_file($userfile["tmp_name"], $dirval.$filename); //Move the uploaded file } //print '<hr>Uploaded'.$uploaded.'<hr>'; if (file_exists($dirval.$filename)){ //Check if the file is uploaded $filename=str_replace('"', '', $filename); $filename=addslashes($filename); $description=addslashes($description); $sqladdmusic =mysql_query("INSERT INTO example ( `username` , `filename` , `filename` , `description` , `server` ) VALUES ( '$username', '$filename', '$filename', '$description', '1')"); showerror('Succesfully uploaded "'.$filename.'"!'); refresh(); } else { if ($correctformat!="true") { showerror('Sorry, file type not allowed.'); } else { showerror('Couldn`t upload "'.$filename.'"'); } } } } else { showerror('Files over 7 MB are not accepted.'); } } } else { showerror('Please enter a file name.'); } } else { showerror('You already have '.$maxfiles.' files uploaded.'); } } $filename=stripslashes($filename); $description=stripslashes($description); ?> <title>Upload File</title> </head> <body bgcolor="#6787B3"> <FORM NAME="sendfile" onSubmit="uploadconfirm();" ENCTYPE="multipart/form-data" ACTION="upload.php" METHOD="post"> <font style="font-size:11px; font-weight:bold;"> MAX filesize: 7 MB<br> You may upload up to <?php print $maxfiles; ?> files total.<p> </font> <input type="file" tabindex="1" name="upload" size="30"><br> File Name<br> <input type="text" tabindex="3" name="filename" value="<?php print $filename; ?>" size="20"><br> Description<br> <textarea name="description" tabindex="4" style="width:300px; height:200px;"><?php print $description; ?></textarea><br> <input type="submit" tabindex="6" name="submit" value="Upload" >   Upload may take a few moments.</center> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/37723-upgrading-server/ Share on other sites More sharing options...
Brendan Posted February 9, 2007 Author Share Posted February 9, 2007 Does anyone know what could have caused this...? Link to comment https://forums.phpfreaks.com/topic/37723-upgrading-server/#findComment-180783 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.