This forum is a community forum meant for users of the plugin to collaborate and help solve issues with implementation, etc. Unfortunately, as the creator of the plugin, I do not have much time to attend to every request here as this is only a side project and I must work a full-time job to provide for my family. This is how I keep the Flash version free and the HTML5 version low cost.
UploadiFive 1.1.1 has been released which includes a small fix for added support on touch devices including iOS 6 devices.
  • Is there a way to prevent uploadify from over writing a file with the same name in the same folder?

    Assuming I have /home/myweb/docs/cashews.doc and I'm uploading a new file called cashews.doc is there a way to rename the newer file to cashews-1.doc before it over writes the file in /home/myweb/docs?

    Hopefully there's an easy solution for this...

    Thanks for any help.

    ampapa,
  • My guess is that you would have to make a few adjustments to the uploadify.php file. I haven't been using the script for very long, but I would check if the file exists in the php file and if it does just amend the filename value in $targetFile.


    if (file_exists($targetFile)) {
    // update to new version
    // ... code to add version and check if that new name exists ...
    $targetFile = str_replace('//','/',$targetPath) . $newfilename;
    }
  • Thanks for the reply.

    I'm a bit green when it comes to coding in javascript...

    If I change the file name to a new name with something as you suggest

    if (file_exists($targetFile)) {
    // update to new version
    // ... code to add version and check if that new name exists ...
    $targetFile = str_replace('//','/',$targetPath) . $newfilename;
    }


    assuming I use a numbering scheme as I pointed out and the new file name I've given the file exists, will it comeback to this routine to be renamed again? will I be able to maintain a count?

    $newfilename= $newfilename+ 1;
  • Well I tried your suggestion without success... uploading the same file had no change?

    if (file_exists($targetFile)) {
    // update to new version
    // ... code to add version and check if that new name exists ...
    $newfilename = "newfilename.doc"
    $targetFile = str_replace('//','/',$targetPath) . $newfilename;
    }

    I see how this makes sense since the move_uploaded_file() function is the script but nothing is happening???
  • Any other suggestions for how to accomplish this?

    ampapa,
  • In case anyone is interested in how I was able to solve (some borrowed source) this here is my script for future reference.

    <?php
    // Uploadify v1.6.2
    // Copyright (C) 2009 by Ronnie Garcia
    // Co-developed by Travis Nickels
    if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_GET['folder'] . '/';

    $file = $_FILES['Filedata']['name'];
    $file = utf8_decode($file);
    $file = ereg_replace(\"[^a-zA-Z0-9_.-\[\]()]\", \"\", strtr($file, \"()áàâãäéèêëíìîïóòôõöúùûüçÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ \", \"[]aaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC_\"));

    $aux_targetPath = str_replace('//','/',$targetPath);
    $targetFile = str_replace('//','/',$targetPath) . $file;

    $returnFile = $_FILES['Filedata']['name'];

    $fnamecnt= 1; //sets a count variable to increment filenames
    while(file_exists($targetFile)) {
    $targetFile = $aux_targetPath . $fnamecnt . \"-\" . $file;
    $fnamecnt = $fnamecnt + 1; //increment count by 1
    }
    move_uploaded_file($tempFile,$targetFile);
    }
    echo \"1\";
    ?>


    ampapa, :D