dongwu8050 2011-04-08 11:49
浏览 22
已采纳

更改Meioupload中的文件名

I'm using Meioupload on a website built with CakePHP, and it is working fine for having multiple upload fields. The problem I have now is that if person A uploads a picture called 'me.jpg' and then person B uploads a picture called 'me.jpg', person B's will overwrite the first upload.

Is there a way in Meioupload to change the filename as the picture is uploaded? E.g. add the person's username to the start so it would look like 'persona_me.jpg' and 'personb_me.jpg'?

This is the code I currently have:

var $actsAs = array('MeioUpload' => array(
    'picture' => array(
        'dir' => 'files/device_images',
        'create_directory' => true,
        'allowed_mime' => array('image/jpeg', 'image/pjpeg', 'image/gif', 'image/png'),
        'allowed_ext' => array('.jpg', '.jpeg', '.png', '.gif'),
        'thumbsizes' => array(
               'small'  => array('width'=>100, 'height'=>100),
               'medium' => array('width'=>240, 'height'=>180),
               'large'  => array('width'=>640, 'height'=>480)
    )));

Thanks for any help

  • 写回答

2条回答 默认 最新

  • dsbezji539113152 2011-04-08 13:01
    关注

    Add this in your Meio Upload declaration: 'uploadName' => 'url_slug', where url_slug is field you are submitting with the form (actually, it might be a field in the schema, it's both on my app).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大