Adding date-time as prefix to the uploading files.

Last post 11-24-2009, 11:36 AM by ashutoshrath. 5 replies.
Sort Posts: Previous Next
  •  11-19-2009, 8:37 AM 57291

    Adding date-time as prefix to the uploading files.

    I would like to upload the files during session wise. i.e when i upload files on a specific session period, it would automatically create a directory named like(2009-11-17,04.30pm) under the root directory "savefiles". Then The files would uploaded to their respective session directories with their file name and a prefix of that session,i.e for example (2009-11-17,04.30pm,abc.jpg).

    I think u understand my thoughts.

    and once again i would like to delete that entire session directories with their files, when ever i would like to delete the record from the database.

    similar thing would happen when updating the records( only files have to delete).
  •  11-19-2009, 9:46 PM 57311 in reply to 57291

    Re: Adding date-time as prefix to the uploading files.

    Hi,
     
    Uploader is a tool to help you upload files.
     
    When the file is uploaded , the uploader will save the file to temp folder at first.
     
    And the name of the file is also a temp name.
     
    You need write code to move the file to your target location , and than maintain it by yourself.
     
    Please check the sample ,
     
    demo2.php and demo2_upload.php
     
    demo2.php use this to specify a handler
     
        $uploader->UploadUrl="demo2_upload.php";
    demo2_upload.php move the file to another place
     
       $targetfilepath= "savefiles/myprefix_" . $mvcfile->FileName;
     
     
    You can modify the demo2_upload.php , and change the prefix as you like.
     
    Regards,
    Terry
  •  11-23-2009, 2:08 PM 57352 in reply to 57311

    Re: Adding date-time as prefix to the uploading files.

    Thanx Terry, for your help. I'll try it. 
  •  11-24-2009, 6:55 AM 57364 in reply to 57311

    Re: Adding date-time as prefix to the uploading files.

    Hello Terry, I had modified the demo2_upload.php file. but still there comes an error.
     
    here is the code and the error.
     
    demo2_upload.php
     
    Here is the error
     
     
     
    Please give some idea to rectify this problem. 
  •  11-24-2009, 9:06 AM 57373 in reply to 57364

    Re: Adding date-time as prefix to the uploading files.

    Hi,
     
    The filename you generated is wrong.
     
    Please do not let the filename contains ':' in the date string.
     
    The filename do not support that char.
     
    Regards,
    Terry
  •  11-24-2009, 11:36 AM 57396 in reply to 57373

    Re: Adding date-time as prefix to the uploading files.

    Thanxx a lot Terry.
    Now , I had done it correctly.
    Now, Would You please tell me, if I would like to save that file into a folder named as it's prefix inside the root directory "savefiles", then wht I have to do ? How and where  I can  create a directory ?
     
    By the way, is there any problem to keep all the files(with prefix) inside a single directory ? or I  have to do whatever I thought above ? 
     

     
     
     
     
View as RSS news feed in XML