Guest User

Untitled

a guest
Sep 11th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. tempname() not working on client server
  2. Warning: ftp_rawlist() [function.ftp-rawlist]: Unable to create temporary file. Check permissions in temporary files directory.
  3.  
  4. define ("LOCALFILE",tempnam('/tmp', 'data-'));
  5. define ("USER","myusername");
  6. define ("PASS","mypassword");
  7. define('SERVER', "ftpserver.com");
  8. define ("DIR","/path/");
  9.  
  10. function getFTPFile(){
  11.  
  12. // connect
  13. if(!($conn_id = @ftp_connect(SERVER))){
  14. Error::throwOne("Could not connect to ".SERVER);
  15.  
  16. };
  17. // login
  18. if(!($login_result = @ftp_login($conn_id, USER, PASS))){
  19. Error::throwOne("LOGIN INCORRECT! user:".USER." pass:".PASS);
  20. };
  21. // try to change the directory to somedir
  22. if (!ftp_chdir($conn_id, DIR)) {
  23. Error::throwOne("Couldn't change directoryn");
  24. };
  25.  
  26. if(!($a = ftp_rawlist($conn_id, '-1t'))){
  27. Error::throwOne("Couldn't get ftp_rawlistn");
  28. };
  29.  
  30. $server_file=($a[0]);
  31. if (!ftp_get($conn_id, LOCALFILE, $server_file, FTP_BINARY)) {
  32. Error::throwOne("Couldn't get filen");
  33. };
  34. ftp_close($conn_id);
  35. };
  36.  
  37. $tmpdir = sys_get_temp_dir();
  38. echo "Temp dir: $tmpdirn";
  39. echo is_writable($tmpdir) ? "Temp dir is writable" : "Temp dir is not writable";
Add Comment
Please, Sign In to add comment