mafap Posted September 1, 2014 Share Posted September 1, 2014 (edited) I have a small php upload/download script, it always worked on older php4 -5 but not on php5.3 ,gobal varitables must be on , I dont know to much about php and was hoping someone will look at at and let me know what to change to make it work on php5.3 or higher..............................THANKS! for any help in fixing this issue <body link="#FFFF00" vlink="#FF0000" alink="#FFFF00"><? $extlimit = "yes"; //Do you want to limit the extensions of files uploaded $limitedext = array(".zip",".sim",".car",".jpg",".gif"); //Extensions you want files uploaded limited to. $sizelimit = "no"; //Do you want a size limit, yes or no? $sizebytes = "30033000"; //size limit in bytes $dl = "xxxxxxxxxxx"; //url where files are uploaded $absolute_path = "xxxxxxxxxxx"; //Absolute path to where files are uploaded $websiteurl = "xxxxxxxx"; //Url to you website $websitename = "Car File Manger"; if (!isset($action)) { $action = ""; } switch($action) { default: echo" <html> <head> <title>Upload Or Download</title> </head> <body> <a href=$PHP_SELF?action=upload>Upload</a> | <a href=$PHP_SELF?action=download>Download</a> | <a href=$websiteurl>Return to $websitename</a> <br><br> </body> </html>"; break; case "download": echo " <html> <head> <title>File Download</title> </head> <body><a href=$PHP_SELF?action=upload>Upload File</a> | <a href=$websiteurl>Return to $websitename</a>"; $list = "<table width=500 border=0 bordercolor=#000000 style=\"border-collapse: collapse\">"; $list .= "<tr><td width=500><center><b>Click To Download</b></center></td></tr>"; $dir = opendir($absolute_path); while($file = readdir($dir)) { if (($file != "..") and ($file != ".")) { //Download files with spaces fix by Kokesh $list .= "<tr><td width=700><a href='$dl/$file'>$file</a></center></td></tr>"; } } $list .= "</table>"; echo $list; echo" <br><br> </body> </html>"; break; case "upload": echo" <html> <head> <title>File Upload</title> </head> <body> <form method=POST action=$PHP_SELF?action=doupload enctype=multipart/form-data> <p>File to upload:<br> <input type=file name=file size=30> <p><button name=submit type=submit> Upload </button> </form> <br><br> </body> </html>"; break; //File Upload case "doupload": $dir = "dir"; if ($file != "") { if (file_exists("$absolute_path/$file_name")) { die("File already exists"); } if (($sizelimit == "yes") && ($file_size > $sizebytes)) { die("File is to big. It must be $sizebytes bytes or less."); } $ext = strrchr($file_name,'.'); if (($extlimit == "yes") && (!in_array($ext,$limitedext))) { die("The file you are uploading doesn't have the correct extension."); } @copy($file, "$absolute_path/$file_name") or die("The file you are trying to upload couldn't be copied to the server"); } else { die("Must select file to upload"); } echo " <html> <head> <title>File Uploaded</title> </head> <body>"; echo $file_name." was uploaded"; echo "<br> <a href=$PHP_SELF?action=upload>Upload </a> | <a href=$PHP_SELF?action=download> Download </a> | <a href=$websiteurl> Return to $websitename</a><br><br> </body> </html>"; break; } ?> Edited September 1, 2014 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted September 1, 2014 Share Posted September 1, 2014 (edited) it always worked on older php4 -5 but not on php5.3 ,gobal varitables must be on Then rewrite the code so it does not depend on register globals. NOTE: Also please wrap code within code tags tags when posting code. For now I have edited your post. Edited September 1, 2014 by Ch0cu3r 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.