         if fs.existsSync(dir+title) is true
           title = title.replace /\.(?=[^.]*$)/, "_"+Date.now()+"_copy."
           file.setFieldValue "title", title
-        copyImages file, true # move = true, only moving
+        file = copyImages file, true # move = true, only moving
+        file.setFieldValue "link", title
       file.save ->
-        console.log("saveFile")
+        console.log("saveFile", file)
         req.io.broadcast 'updateCollection', cfg.collectionName
 
 
   app.post "/uploadFile", auth, (req,res)->
-    console.log("uploadFile")
     form = new multiparty.Form
     form.parse req, (err, fields, files)->
       if err then return console.log 'formparse error', err

    newFileName = oldFileName.replace /\.(?=[^.]*$)/, "_"+Date.now()+"_copy."
    fs.writeFileSync dir+newFileName, fs.readFileSync dir+oldFileName
    file.setFieldValue 'link', newFileName
    createImages file, req
    file.setFieldValue 'title', newFileName
    file.save ->
      req.io.broadcast "updateCollection", "Files"


      portrait = true if size.width < size.height
      addFile = (type, cb)->
        maxSize = moduleSetting.getFieldValue type
        targetName = filename.replace /\.(?=[^.]*$)/, '_'+type+'.'
        file.setFieldValue type, targetName
        image.quality parseInt(moduleSetting.fields.quality.value)
        if portrait then image.resize null, maxSize
