lewis987 Posted August 10, 2007 Share Posted August 10, 2007 Hey guys, me again lol this time ive created a Client and remote upload script to upload these file types: jpg, JPG, gif, png, PNG, bmp, zip, ZIP, rar, RAR, exe and EXE the problem is, if the user uploads say an EXE through FTP, it give me an error. HTTP works perfectly. I just cant get the FTP to work with exe, EXE, rar, RAR, zip or ZIP. it works fine with images... just not them. here is the remote upload part of it: if($_POST['go1']){ if($mktime >= $uploadwait){ if($_POST['files'] == ""){ echo "You cannot use an empty Field!"; } else { $string = " " . $_POST['files']; $find = "http://"; $found1 = strpos($string, $find); if($found1 == FALSE){ $find = "ftp://"; $found2 = strpos($string, $find); if($found2 == FALSE){ echo "Cannot use the protocol."; } else { $found = strstr($string, $find); $find2 = "/"; $findLast = strrchr($found, $find2); $Exp = explode(".", $findLast); if(!$Exp){ echo "Invalid File..."; } else { if(($Exp[1] === "jpg") || ($Exp[1] === "gif") || ($Exp[1] === "JPG") || ($Exp[1] === "jpeg") || ($Exp[1] === "png") || ($Exp[1] === "PNG") || ($Exp[1] === "bmp") || ($Exp[1] === "exe") || ($Exp[1] === "EXE") || ($Exp[1] === "zip") || ($Exp[1] === "ZIP") || ($Exp[1] === "rar") || ($Exp[1] === "RAR")){ if(($Exp[1] === "exe") || ($Exp[1] === "EXE") || ($Exp[1] === "zip") || ($Exp[1] === "ZIP") || ($Exp[1] === "rar") || ($Exp[1] === "RAR")){ $md5name = $findlast; $copy = copy($found, "files" . $md5name); } else { $md5 = md5(mktime()); $md5name = $md5 . "." . $explode[1]; $copy = copy($found, "files/" . $md5name); } if(!$copy){ echo "Unable to download file onto the server."; } else { $file = "files/" . $md5name; if(filesize($file) > $fileSizeLimit){ unlink($file); echo "File to large"; } else { if(fopen("files/" . $md5name)){ echo "File already exists!"; } else { echo "Download Complete of the file: " . $findlast . " (named as: {$md5name})<br />"; echo "<a href='files/".$md5name."'>Click here</a> to view your upload."; $_SESSION['time'] = $finaltime; } } } } else { echo "File type invalid"; } } } } else { $found = strstr($string, $find); $find1 = "/"; $findlast = strrchr($found, $find1); $explode = explode(".", $findlast); if(!$explode){ echo "Invalid file..."; } else { if(($explode[1] === "jpg") || ($explode[1] === "gif") || ($explode[1] === "JPG") || ($explode[1] === "jpeg") || ($explode[1] === "png") || ($explode[1] === "PNG") || ($explode[1] === "bmp") || ($explode[1] === "exe") || ($explode[1] === "EXE") || ($explode[1] === "ZIP") || ($explode[1] === "zip") || ($explode[1] === "rar") || ($explode[1] === "RAR")){ if(($explode[1] === "exe") || ($explode[1] === "EXE") || ($explode[1] === "ZIP") || ($explode[1] === "zip") || ($explode[1] === "rar") || ($explode[1] === "RAR")){ $md5name = $findlast; $copy = copy($found, "files" . $md5name); } else { $md5 = md5(mktime()); $md5name = $md5 . "." . $explode[1]; $copy = copy($found, "files/" . $md5name); } if(!$copy){ echo "Unable to download file onto the server."; } else { $file = "files/" . $md5name; if(filesize($file) > $fileSizeLimit){ unlink($file); echo "File to large"; } else { if(fopen("files/" . $md5name)){ echo "File already exists!"; } else { echo "Download Complete of the file: " . $findlast . " (named as: {$md5name})<br />"; echo "<a href='files/".$md5name."'>Click here</a> to view your upload."; $_SESSION['time'] = $finaltime; } } } } else { echo "File type invalid"; } } } } } else { echo '<table border="0" cellspacing="0" cellpadding="0"> <tr> <td bgcolor="#FF0000" height="2" width="2"></td> <td bgcolor="#FF0000"></td> <td bgcolor="#FF0000" height="2" width="2"></td> </tr> <tr> <td bgcolor="#FF0000" height="2"></td> <td bgcolor="#FFaaaa">You have not waited long enough before uploading again.</td> <td bgcolor="#FF0000" height="2"></td> </tr> <tr> <td bgcolor="#FF0000" height="2" width="2"></td> <td bgcolor="#FF0000"></td> <td bgcolor="#FF0000" height="2" width="2"></td> </tr> </table>'; } echo "</body>"; echo "</html>"; exit; } This is the specific FTP part of it: $found = strstr($string, $find); $find2 = "/"; $findLast = strrchr($found, $find2); $Exp = explode(".", $findLast); if(!$Exp){ echo "Invalid File..."; } else { if(($Exp[1] === "jpg") || ($Exp[1] === "gif") || ($Exp[1] === "JPG") || ($Exp[1] === "jpeg") || ($Exp[1] === "png") || ($Exp[1] === "PNG") || ($Exp[1] === "bmp") || ($Exp[1] === "exe") || ($Exp[1] === "EXE") || ($Exp[1] === "zip") || ($Exp[1] === "ZIP") || ($Exp[1] === "rar") || ($Exp[1] === "RAR")){ if(($Exp[1] === "exe") || ($Exp[1] === "EXE") || ($Exp[1] === "zip") || ($Exp[1] === "ZIP") || ($Exp[1] === "rar") || ($Exp[1] === "RAR")){ $md5name = $findlast; $copy = copy($found, "files" . $md5name); } else { $md5 = md5(mktime()); $md5name = $md5 . "." . $explode[1]; $copy = copy($found, "files/" . $md5name); } if(!$copy){ echo "Unable to download file onto the server."; } else { $file = "files/" . $md5name; if(filesize($file) > $fileSizeLimit){ unlink($file); echo "File to large"; } else { if(fopen("files/" . $md5name)){ echo "File already exists!"; } else { echo "Download Complete of the file: " . $findlast . " (named as: {$md5name})<br />"; echo "<a href='files/".$md5name."'>Click here</a> to view your pload."; $_SESSION['time'] = $finaltime; } } } } else { echo "File type invalid"; } } thanks in advance... Quote Link to comment https://forums.phpfreaks.com/topic/64272-solved-remote-upload-script-problem/ Share on other sites More sharing options...
lewis987 Posted August 10, 2007 Author Share Posted August 10, 2007 no-one know the answer? Quote Link to comment https://forums.phpfreaks.com/topic/64272-solved-remote-upload-script-problem/#findComment-320743 Share on other sites More sharing options...
MadTechie Posted August 10, 2007 Share Posted August 10, 2007 and the "error" is ? also use str2lower() it will save alot of time.. Quote Link to comment https://forums.phpfreaks.com/topic/64272-solved-remote-upload-script-problem/#findComment-320748 Share on other sites More sharing options...
lewis987 Posted August 10, 2007 Author Share Posted August 10, 2007 when i try and download a file with the extension of rar, zip or exe (caps or not) via ftp it cant copy it to the files folder, it can do images fine Quote Link to comment https://forums.phpfreaks.com/topic/64272-solved-remote-upload-script-problem/#findComment-320765 Share on other sites More sharing options...
MadTechie Posted August 10, 2007 Share Posted August 10, 2007 change if(($Exp[1] === "exe") || ($Exp[1] === "EXE") || ($Exp[1] === "zip") || ($Exp[1] === "ZIP") || ($Exp[1] === "rar") || ($Exp[1] === "RAR")){ $md5name = $findlast; $copy = copy($found, "files" . $md5name); } to if(($Exp[1] === "exe") || ($Exp[1] === "EXE") || ($Exp[1] === "zip") || ($Exp[1] === "ZIP") || ($Exp[1] === "rar") || ($Exp[1] === "RAR")){ $md5name = $findlast; $copy = copy($found, "files/" . $md5name); } Quote Link to comment https://forums.phpfreaks.com/topic/64272-solved-remote-upload-script-problem/#findComment-320780 Share on other sites More sharing options...
lewis987 Posted August 11, 2007 Author Share Posted August 11, 2007 Warning: copy(files) [function.copy]: failed to open stream: Permission denied in -------\extras\goddy\index1.php on line 144 so i know its a copy problem, Chmod is NOT an option as i am testing on a windows server... Quote Link to comment https://forums.phpfreaks.com/topic/64272-solved-remote-upload-script-problem/#findComment-321019 Share on other sites More sharing options...
lewis987 Posted August 11, 2007 Author Share Posted August 11, 2007 fixed it, had to proofread my code, i set the variable to $findlast instead of $findLast thanks anyway Quote Link to comment https://forums.phpfreaks.com/topic/64272-solved-remote-upload-script-problem/#findComment-321029 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.