UPLOAD problem LAVALAIR pls help me.

Started on the old forum in August 2010 · view the original in the archive · old links redirect here

4 replies · 826 views · started 16 years ago · 1 min read

4 participants
leadiztah Developer · 55 posts #1

i have a script of a modified lavalair script.. but my problem is about uploading files on my host server.. my host is only freehosting. // on my localhost(PC)>> XAMMP.. it is working.. the files go to the directory when i upload the file.. but on my host.. the script running successfully.. but the file did not copy or place on the directory.. i think because i have a problem with the FTP on my script.. im going to give you the script of mine..

<?php include("../web/core.php"); include("../web/config.php"); connectdb(); $uip = getip(); $action = $_GET["action"]; $sid = $_GET["sid"]; $page = $_GET["page"]; $who = $_GET["who"]; $uid = getuid_sid($sid); $sid = $_GET["sid"]; $site = $_GET["site"]; $theme = mysql_fetch_array(mysql_query("SELECT theme FROM ibwf_users WHERE id='".$uid."'")); $sitename = mysql_fetch_array(mysql_query("SELECT value FROM ibwf_settings WHERE name='sitename'")); $sitename = $sitename[0]; echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html"/> <meta http-equiv="Cache-Control" content="no-cache" forua="true"/>'; echo "<title>$sitename Upload Files</title>"; echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">"; echo "</head>"; echo "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000FF\" vlink=\"#800080\">"; if ($upload="upload"&&$superdat_name){ if (!eregi("\.(mid|zip|bmp|mid|midi|3gp|mp3|wav|jar|jad|nth|rar|sis|mmf|amr|sisx|txt)$",$superdat_name)){ print "**Unsupported File Extention!**"; }else{ $superdat_name = preg_replace( '/[^a-zA-Z0-9\.\$\%\'\`\-\@\{\}\~\!\#\(\)\&\_\^]/' ,'',str_replace(array(' ','%20',"'"),array('_','_', ""),$superdat_name)); if(strlen($superdat_name)>53){ print "**File Name Is Too Long!**"; }else{ if (empty($superdat)) { print "**No input file specified!!!**"; }else{ copy($connection,$superdat,"files/$superdat_name",FTP_BINARY) or die("Couldn't copy file."); $date=(date("D, j F Y")); $fsize=round($superdat_size/1024,1); $text = "&&$superdat_name&&$fsize KB&&$date&&$REMOTE_ADDR&&"; $fz = "$fsize KB"; if("$text"!="$check[1]"){ $mysql=mysql_query("INSERT INTO ibwf_uploads SET id='', uid='".$uid."', filename='".$superdat_name."', filesize='".$fsize." KB', date='".$date."', uip='".$REMOTE_ADDR."'"); echo mysql_error(); } echo "**$superdat_name** Has Been Successfully Uploaded"; } } } } ?> <?php echo "<FORM align=\"center\" ACTION=\"upload.php?sid=$sid&amp;site=$site\" METHOD=\"POST\" ENCTYPE=\"multipart/form-data\">"; ?>

Select File :

<input align="center" type="file" name="superdat"> <input align="center" type="hidden" name="upload" value="upload"/> <INPUT align="center" TYPE=SUBMIT NAME="submit" VALUE="Upload File!">

Allowed Extensions:

.sisx, .nth, .mid, .midi, .mpg, .mmf, .amr, .mp3, .wav, .wmv , .avi, .3gp, .sis, .jar, .jad, .zip, .rar, .txt


<?php echo " <a href=\"index.php?sid=$sid&amp;site=$site\">Filesharing Menu</a>"; ?> </FORM> <?php

if($site=="wap"){ echo "

<a href="../wap/index.php?action=main&sid=$sid"><img src="../images/home.gif" alt=""/>Home</a>"; }else{ echo "

<a href="../web/index.php?action=main&sid=$sid"><img src="../images/home.gif" alt=""/>Home</a>"; } ?>

</body> </html>

this is the FTP script on core..

function FtpUpload($dest_file, $src_file){

// set up basic connection

$server= "server"; // ftp server

$connection = ftp_connect($server); // connection

// login to ftp server

$user = "user";

$pass = "pass";

$result = ftp_login($connection, $user, $pass);

// check connection

if ((!$connection) || (!$result)) {

   echo "FTP connection has failed!";

   echo "Attempted to connect to $ftp_server for user $ftp_user_name"; 

   exit; 

}

// upload the file

$upload = ftp_put($connection, $dest_file, $src_file, FTP_BINARY);

// check upload status

if (!$upload) {

   echo "FTP upload has failed!";

}

// close the FTP stream

ftp_close($connection);

}

i tried to set the server user and password..depend on my FTP server.. but nothings happen.. look at the script of the UPLOAD.php there is no FTP script where you can see @ core.php

plss help me. what is the problem.. huhuh

leadiztah Developer · 55 posts #4

i know that my script is not yet sanitize.. but im focusing on my problem.. on how to upload files.. somebody help me plss

something else Fellow · 2,296 posts #5

globals are turned off so you will need to collect your data:

$superdat = $_FILES['superdat']['tmp_name'];
$superdat_name=$_FILES['superdat']['name'];
$superdat_size=$_FILES['superdat']['size'];

MAKE SURE YOU SECURE YOUR UPLOADER!!!!

also advice:

this can be shortened lots:

<?php echo "<br/><small><a href=\"index.php?sid=$sid&site=$site\">Filesha ring Menu</a></small>"; ?>
</FORM>
<?php

if($site=="wap"){
echo "<br/><br/><a href=\"../wap/index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
}else{
echo "<br/><br/><a href=\"../web/index.php?action=main&sid=$sid\"><img src=\"../images/home.gif\" alt=\"\"/>Home</a>";
}
?>

to something like:

<br/><small><a href="index.php?sid=<?=$sid?>&site=<?=$site?>">Filesha ring Menu</a></small>
</FORM>
<br/><br/><a href="http://coding-talk.com/<?=$site?>/index.php?action=main&sid=<?=$sid?>"><img src="http://coding-talk.com/images/home.gif" alt=""/>Home</a>

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close