Ik heb deze code:
index.php:
ik heb het grootste deel van de HTML code eruit geript omdat die verder niet interessant is voor de php code.
functions.php:
De grap zit dus hier: op mijn localhost heb ik Apache draaien, en hier werkt het script naar behoren. Nu heb ik het op endoria gedraaid (heeft ook ftp support, ondersteunt alle functies), maar daar krijg ik zowel bij downloaden als uploaden een error in de trant van 'could not open file bestandsnaam'
Heeft iemand een idee waar dit nou weer aan kan liggen? Dit irriteert me namelijk zwaar, dit script moet ik binnenkort echt draaiende hebben.
index.php:
PHP:
1
| <?<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head> <title>FTP Upload form</title><script language="JavaScript">self.resizeTo(400,500);self.scrollbars = 1;</script><link rel="stylesheet" href="http://www.horizondd.nl/style.css" type="text/css"><?include 'functions.php';$user = 'gebruikersnaam';$ftp_server = 'ftpserveradres';$ftp_dir = '/www/naar/HTML/dir/'.$user.'/download/';$ftp_user_name = 'ftpuser';$ftp_user_pass = 'ftppass';// set up basic connection$conn_id = ftp_connect($ftp_server); // login with username and password$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connectionif ((!$conn_id) || (!$login_result)) { echo "Ftp connection has failed!"; echo "Attempted to connect to $ftp_server for user $ftp_user_name"; die; } else { //echo "Connected to $ftp_server, for user $ftp_user_name<br><br>"; }if( $a == 'upload' ) { uploadFile($source_file, $destination_file, $conn_id); }if ( $a == 'download' ) { downloadFile($source_file, $conn_id, $user); }?><style> .kopje2 { color : Black; font : bold; }</style></head><body style="margins: 0 0 0 0;"><table width="100%" align="center"><tr><td><form name="uploadform" method="get"><input type="Hidden" name="a" value="upload"><table><tr><td><input class="file" type="File" name="source_file"></td><td><input type="Text" name="destination_file"></td></tr><tr><td colspan="2"><input type="Submit" value="Upload File"></td></tr></form></table><br><table><tr><td class="kopje2">Files available for download:</td></tr><tr><td><?listFiles("gebruikersnaam", $conn_id, $ftp_dir);?></td></tr></table></td></tr></table></body></html>?> |
ik heb het grootste deel van de HTML code eruit geript omdat die verder niet interessant is voor de php code.
functions.php:
PHP:
1
| <?function listFiles($user, $conn_id, $ftp_dir){ftp_chdir($conn_id, $ftp_dir);//echo "current dir: ";//echo ftp_pwd($conn_id) . "<br>";$filelist = ftp_nlist($conn_id, $ftp_dir); //filelist is arrayfor ( $i = 0; $i < count($filelist); $i++ ) { $file = explode ($ftp_dir, $filelist[$i]); echo "<br><a href=\"index.php?a=download&source_file=$file[1]\">$file[1]</a>"; }if ( count($filelist) < 2 ) { echo "<i>There are currently no downloads available.</i>"; }}function uploadFile($source_file, $destination_file, $conn_id){$source_file = stripslashes($source_file);echo "<br>current dir: ";echo ftp_pwd($conn_id);ftp_chdir($conn_id, '/www/naaruploaddir/HTML/upload');echo "<br>current dir: ";echo ftp_pwd($conn_id);// upload the file$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); // check upload statusif (!$upload) { echo "Ftp upload has failed!"; } else { echo "Uploaded $source_file to $ftp_server as $destination_file"; }// close the FTP stream //ftp_quit($conn_id); }function downloadFile($source_file, $conn_id, $user){$ftp_server = 'ftpservernaam';$ftp_dir = '';$ftp_user_name = 'ftpuser';$ftp_user_pass = 'ftppass';// set up basic connection$conn_id = ftp_connect($ftp_server); // login with username and password$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connectionif ((!$conn_id) || (!$login_result)) { echo "Ftp connection has failed!"; echo "Attempted to connect to $ftp_server for user $ftp_user_name"; die; } else { echo "Connected to $ftp_server, for user $ftp_user_name<br><br>"; }#bool ftp_get ( resource ftp_stream, string local_file, string remote_file, int mode)echo "$conn_id<br>$source_file<br>";ftp_get ( $conn_id, "C:\\Documents And Settings\\Administrator\\Desktop\\".$source_file, "/www/padnaardownloaddir/HTML/$user/download/".$source_file, FTP_BINARY );}?> |
De grap zit dus hier: op mijn localhost heb ik Apache draaien, en hier werkt het script naar behoren. Nu heb ik het op endoria gedraaid (heeft ook ftp support, ondersteunt alle functies), maar daar krijg ik zowel bij downloaden als uploaden een error in de trant van 'could not open file bestandsnaam'
Heeft iemand een idee waar dit nou weer aan kan liggen? Dit irriteert me namelijk zwaar, dit script moet ik binnenkort echt draaiende hebben.