FROM THE BLOG RSSRSS Feed   |   Visit our blog »

  • Uploading files to FTP server from PHP Script


    For one of my project I was required to upload files on an FTP server from the PHP script. Searching on Google I found code required but it was not completely available at one place. So I thought to share this here for use by others as tried and tested code, working on a live website.

    This script was created for moving the just uploaded file to FTP server. That is why it uses $_FILES["tmp_name"] as local file. You can change to your file location, if it is already uploaded.

     

    Please replace the variables in first four lines according to the settings you have for your target FTP server.


    $ftp_server = "ftp.yourserver.com";
    $ftp_user_name = "ftpuser";
    $ftp_user_pass = "ftppassword";
    $remote_dir = "/target/folder/on/ftp/server";

    // 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);

    //default values
    $file_url = "";

    if($login_result) {
    //set passive mode enabled
    ftp_pasv($conn_id, true);

    //check if directory exists and if not then create it
    if(!@ftp_chdir($conn_id, $remote_dir)) {
    //create diectory
    ftp_mkdir($conn_id, $remote_dir);
    //change directory
    ftp_chdir($conn_id, $remote_dir);
    }

    $file = $_FILES["file"]["tmp_name"];
    $remote_file = $_FILES["file"]["name"];

    $ret = ftp_nb_put($conn_id, $remote_file, $file, FTP_BINARY, FTP_AUTORESUME);
    while(FTP_MOREDATA == $ret) {
    $ret = ftp_nb_continue($conn_id);
    }

    if($ret == FTP_FINISHED) {
    echo "File '" . $remote_file . "' uploaded successfully.";
    } else {
    echo "Failed uploading file '" . $remote_file . "'.";
    }
    } else {
    echo "Cannot connect to FTP server at " . $ftp_server;
    }


    Posted on January 9, 2013
  • Type in your language using Microsoft Indic Language Input tool


    Though most of my work involves use of English as primary language, my mother tongue is Hindi. So when I want to write blog posts or some other personal communication with my closed friends, sometimes I feel the need to be able to type in Hindi. Earlier I was using Google Transliterate tool, but that required 2-3 steps for this. First I need to open the web app of Google then type there and then copy and paste it in required location. This also caused some font issues in my office tool LibreOffice.

    So I started looking for some onscreen keyboard using which I can directly type in Hindi. While Googling about this, I stumbled upon this tool from Microsoft itself which directly enables me to input text in Hindi using the transliteration. Meaning I need to type in English the word as it is pronounced in Hindi and the tool automatically converts that to Hindi font. And using this I can type in Hindi at any place in Windows Operating system. That was exactly what I needed, and I was surprised how I did not know about this. I never heard or read about this though I have subscribed for almost all technology blogs and news sites.

    Anyway – I thought it may be of help to someone reached here – you can download the tool for your language here - http://www.bhashaindia.com/ilit/Hindi.aspx. The link is for Hindi language tool but you can find on the same page input tool for other languages like – Bengali, Gujrati, Kannada, Malyalam, Marathi, Oriya, Punjabi, Tamil and Telugu.


    Posted on December 17, 2012
  • Fix Error 0×80070424 on windows


    Recently while visiting a website I got infected by Live Security Platinum malware which disabled all security services on my PC. I was able to remove this using the free Malware Bytes Anti spyware tool. But the Windows firewall and McAfee firewall were unable to run due to some bugs made in the windows. As usual I started looking on Google for the solutions posted by others for similar problem. I found many proposed solutions mentioning issue in McAfee and re-installing it after clean removal. But none of them look promising to me.

    Then today I landed on Microsoft Fix It Solution center. I came to know that Microsoft has already provided lots of automated tools to check and fix common problems in various windows version. When searched for my problem I landed on this page:

    http://support.microsoft.com/kb/968002

    You need to download small software pieces and execute them to check and fix your PC. And I am very thankful to them that this solved my problem. Hope this helps you too.


    Posted on September 6, 2012

CLIENTS THAT LOVE US

  • ~ Elance ID – gtownwebdev

    "Nirvaat was responsive, fast, knowledgeable, professional and the price was great. I am thrilled to have found"

  • ~ Elance ID – robalfano

    "Excellent web developer. Has a great understanding of web projects and how to turn that into a working application online. I couldn't be more satisfied with the"

  • ~ Elance ID – catchlight

    "This was a seemingly small job, but a very important one and one that needed to be done right. A certain level of knoowledge is required for this type of task and nirvaat carried it out beautyifully. Nice work and I'd reccommend this provider to anyone working with"

  • ~ Elance ID – ingariza

    "This is the first time I used Elance, and I was blessed having Nirvaat as my provider, very professional, pro-active, great communication , on-time delivery, solve every problem I had. I recommend Nirvaat if you want your job on time, with quality and great support. Thanks"

  • Read more testimonials »

Popular posts