Renaming Uploaded File

Hi, I am trying to figure out a way to automatically rename a
file as it is uploaded by a user of my website based on a
recordset. Does anyone have any idea on how to do this. The file
will not be just one type but both images (JPG) and video (AVI).
Thanks,
Craig

How easy this will be depends upon the server langauge that
you are using.
Paul Whitham
Certified Dreamweaver MX2004 Professional
Adobe Community Expert - Dreamweaver
Valleybiz Internet Design
www.valleybiz.net
"h2ojefe" <[email protected]> wrote in
message
news:e7b1aq$pum$[email protected]..
> Hi, I am trying to figure out a way to automatically
rename a file as it
> is
> uploaded by a user of my website based on a recordset.
Does anyone have
> any
> idea on how to do this. The file will not be just one
type but both images
> (JPG) and video (AVI).
>
> Thanks,
> Craig
>

Similar Messages

  • Return renamed uploaded file name

    Hey,
    I'm trying to upload a file from flash(selected via
    filereference) via php, i rename(in php) the file before uploading
    it. this isn't a problem and works great but then i need to return
    the new filename to flash so i can save a link to it in my
    database.
    my biggest problem is that i use file.upload(phpScriptPath)
    to upload the file. But if i use the echo command in php to return
    newFilename i don't know how to capture this information in flash.
    does anybody help me out?
    thx on advance

    You can't return the new filename using the FileReference
    object so you need a workaround. From what you posted here I can't
    put my finger on the right solution but to illustrate:
    I needed a solution as part of a form where the user would
    provide name, email and so on and could upload a c.v. Before the
    file upload I used a LoadVars (and used the sendAndLoad() method)
    object to post the data from the form and return the record_id from
    the database. In the onLoad event of the LoadVars object I used the
    FileReference object to handle the upload, calling an upload script
    and added the record_id as a get variable. The record_id was then
    used to save the new filename of the uploaded file to the database.
    If this is not feasible in your situation, elaborate on the
    topic by describing your scenario in more detail.

  • File Upload File Renaming

    I was wondering if anyone knows how to set up a trigger to automatically rename a file on upload to change spaces into underscores using DToolbox image and resize feature. An example is from "My picture.jpg" to "My_picture.jpg". I also wonder if this could be part of a form validation? Maybe using a spry widget?
    I have no experience with triggers, and especially the adobe tng.FileUpload.class.php file (which I assume is where to change the trigger? or maybe it's in the tng.ImageUpload.class.php file?)
    Thanks for the help!
    -Chris

    Hi Chris,
    fotunately I already made such a modification to ADDT´s predecessor "MX Kollection", and as the core files didn´t change, it will assumingly work the same:
    1. add the following function to the file "includes/common/KT_functions.inc.php":
    replace all chars from uploaded filenames other than alpha-numeric and "_" and "-" and "." with an underscore (_)
    function KT_websafe_filename($text) {
    return preg_replace("/[^a-zA-Z0-9\-_\.]+/", "_", $text);
    2. change line 120 in file "includes/common/lib/file_upload/KT_FileUpload.class.php":
    old: $fileName = KT_replaceSpecialChars($fileName, 'filter');
    new: $fileName = KT_websafe_filename($fileName, 'filter');
    This modification will of course *always* be renaming the uploaded file accordingly -- but you´ll need no fancy trigger and anything else.
    Please backup the 2 original files !!
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Automatically renaming an uploaded file

    I am creating a page to upload files, as well as to submit
    data about the file to be stored in a database. When the form data
    is submitted, how can I program it to automatically rename the
    uploaded file to the ID or Key number of the row in the database in
    which the file's information is stored?

    What scripting language are you using?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "AngryCloud" <[email protected]> wrote in
    message
    news:evmlp4$lfh$[email protected]..
    >I am creating a page to upload files, as well as to
    submit data about the
    >file
    > to be stored in a database. When the form data is
    submitted, how can I
    > program
    > it to automatically rename the uploaded file to the ID
    or Key number of
    > the row
    > in the database in which the file's information is
    stored?
    >

  • Creaky MuVo battery pack? Also, warmness after uploading files (renamed thre

    Sorry to keep making threads about little things, but I reckon it's worth checking. My MuVo feels quite a bit hotter after I upload files to it (completely fill over USB2.0 usually). It cools down in a few minutes, but I thought I'd check to see if it's normal behaviour. If it's relevant, the USB connector on the main bit (with the controls) is squint (angled towards the screen face of the player).
    Also, my battery module's a bit creaky. When I press buttons on the player or swap the battery I can feel it creaking into different positions. The main player doesn't do this on its own, so I'm wondering if all the battery modules are like that. If not, I might send off for a new battery module as it's only about ?9 and it'd really improve the feel of the player (I hate cheap-feeling plastic if it's something I'm handling a lot).
    Edit- Just to elaborate on the "creaky" thing, the battery pack feels really loose and plasticky on its own and when the main player bit's plugged in. This makes the whole thing feel a bit fiddly, creaking when I press down on buttons or the scroller, when in fact the player bit itself feels solid on its own.
    Now, if I pop the player in the belt clip holster widget, it suddenly "tightens" up, presumably because the holster is pressing in around the player. It feels really, really solid. Is the problem shared by all the battery packs, or have I just mistreated mine a bit's If it's the latter I'll nab a new battery pack.Message Edited by Sockatume on 06-20-2005 03:44 AM

    My Zen Micro heated up a bit when I was charging/transferring files too. I just unplugged it and in a few minutes it was fine. So that seems to be normal. Don't know about the other problem though, sorry.

  • Adobe Muse won't publish (Error uploading file)

    After making simple animations using Adobe Edge Animate it seems as though none of the assets will publish with my site after importing them into Muse.
    In Edge animate I saved for "web animation" and published. Then I went to muse and hit "place". I went to preview and everything works fine. When I go to publish there are always errors in uploading my assets with '.png' extensions.
    Any help is much appreciated. I have completely scrapped my website and created another, reinstalled Animate and have renamed all my files, I'm not sure whats wrong here.
    I got one animation working, and that can be seen here under the Photography section, but I have multiples that will be shown on my page at one time.
    http://chasebodydesign.businesscatalyst.com

    I get the error uploading file everytime I try publishing the animation.

  • Change upload file name with com.oreilly.servlet.MultipartRequest to handle the file upload

    1. when use com.oreilly.servlet.MultipartRequest to handle the file upload, can I change the upload file name .
    2. how com.oreilly.servlet.MultipartReques handle file upload? do it change to byte ?
    what  different?  if I use the following method?
       File uploadedFile = (File) mp.getFile("filename");
                   FileOutputStream fos = new FileOutputStream(filename);
                    byte[] uploadedFileBuf = new byte[(int) uploadedFile.length()];
                   fos.write(data);
                 fos.close();

    My questions are
    1) when use oreilly package to do file upload , it looks like i line of code is enough to store the upload file in the
    file direction.
    MultipartRequest multi =
            new MultipartRequest(request, dirName, 10*1024*1024); // 10MB
    why some example still use FileOutputStream?
    outs = new FileOutputStream(UPLOADDIR+fileName); 
        filePart.writeTo(outs); 
       outs.flush(); 
      outs.close();
    2) can I rename the file name when I use oreilly package?

  • Problem when trying to rename uploaded images using session value

    Hi,
    I have a form where 9 images are uploaded made into thumb nail size and then stored in a file. What I´m trying to do is rename those thumbnails from their original name to username_0, username_1, username_2 etc for each of the 9 thumbs. The username comes from the registration form on the same page. I have created a session variable for the username and am trying to use that to change to name of the image name, whilst my images are uploading and resizing the name stays as the original and not as the new username_$number. I have pasted relevant code below and would very much appreciate any help with this:
    <?php session_start();
    // check that form has been submitted and that name is not empty and has no errors
    if ($_POST && !empty($_POST['directusername'])) {
    // set session variable
    $_SESSION['directusername'] = $_POST['directusername'];
    // define a constant for the maximum upload size
    define ('MAX_FILE_SIZE', 5120000); 
    if (array_key_exists('upload', $_POST)) {
    // define constant for upload folder
    define('UPLOAD_DIR', 'J:/xampp/htdocs/propertypages/uploads/');
    // convert the maximum size to KB
    $max = number_format(MAX_FILE_SIZE/1024, 1).'KB';
    // create an array of permitted MIME types
    $permitted = array('image/gif','image/jpeg','image/pjpeg','image/png');
    foreach ($_FILES['photo']['name'] as $number => $file) {
    // replace any spaces in the filename with underscores
    $file = str_replace(' ', '_', $file);
    // begin by assuming the file is unacceptable
    $sizeOK = false;
    $typeOK = false;
    // check that file is within the permitted size
    if ($_FILES['photo']['size'] [$number] > 0 && $_FILES['photo']['size'] [$number] <= MAX_FILE_SIZE) {
    $sizeOK = true;
    // check that file is of a permitted MIME type
    foreach ($permitted as $type) {
    if ($type == $_FILES['photo']['type'] [$number]) {
    $typeOK = true;
    break;
    if ($sizeOK && $typeOK) {
    switch($_FILES['photo']['error'] [$number]) {
    case 0:
    include('Includes/create_thumbs.inc.php');
    break;
    case 3:
    $result[] = "Error uploading $file. Please try again.";
    default:
    $result[] = "System error uploading $file. Please contact us for further assistance.";
    elseif ($_FILES['photo']['error'] [$number] == 4) {
    $result[] = 'No file selected';
    else {
    $result[] = "$file cannot be uploaded. Maximum size: $max. Acceptable file types: gif, jpg, png.";
    ................CODE BELOW IS THE INCLUDES FILE THAT MAKES AND TRIES TO RENAME THE THUMBS................................................
    <?php
    // define constants
    define('THUMBS_DIR', 'J:/xampp/htdocs/propertypages/uploads/thumbs/');
    define('MAX_WIDTH_THB', 75);
    define('MAX_HEIGHT_THB', 75);
    set_time_limit(600);
    // process the uploaded image
    if (is_uploaded_file($_FILES['photo']['tmp_name'][$number] )) {
    $original = $_FILES['photo']['tmp_name'][$number] ;
    // begin by getting the details of the original
    list($width, $height, $type) = getimagesize($original);
    // check that original image is big enough
    if ($width < 270 || $height < 270) {
    $result[] = 'Image dimensions are too small, a minimum image of 270 by 270 is required';
    else { // crop image to a square before resizing to thumb
    if ($width > $height) {
    $x = ceil(($width - $height) / 2);
    $width = $height;
    $y = 0;
    else if($height > $width) {
    $y = ceil(($height - $width) / 2);
    $height = $width;
    $x = 0;
    // calculate the scaling ratio
    if ($width <= MAX_WIDTH_THB && $height <= MAX_HEIGHT_THB) {
    $ratio = 1;
    elseif ($width > $height) {
    $ratio = MAX_WIDTH_THB/$width;
    else {
    $ratio = MAX_HEIGHT_THB/$height;
    if (isset($_SESSION['directusername'])) {
    $username = $_SESSION['directusername'];
    // strip the extension off the image filename
    $imagetypes = array('/\.gif$/', '/\.jpg$/', '/\.jpeg$/', '/\.png$/');
    $name = preg_replace($imagetypes, '', basename($_FILES['photo']['name'][$number]));
    // change the images names to the user name _ the photo number
    $newname = str_replace ('name', '$username_$number', $name);
    // create an image resource for the original
    switch($type) {
    case 1:
    $source = @ imagecreatefromgif($original);
    if (!$source) {
    $result = 'Cannot process GIF files. Please use JPEG or PNG.';
    break;
    case 2:
    $source = imagecreatefromjpeg($original);
    break;
    case 3:
    $source = imagecreatefrompng($original);
    break;
    default:
    $source = NULL;
    $result = 'Cannot identify file type.';
    // make sure the image resource is OK
    if (!$source) {
    $result = 'Problem uploading image, please try again or contact us for further assistance';
    else {
    // calculate the dimensions of the thumbnail
    $thumb_width = round($width * $ratio);
    $thumb_height = round($height * $ratio);
    // create an image resource for the thumbnail
    $thumb = imagecreatetruecolor($thumb_width, $thumb_height);
    // create the resized copy
    imagecopyresampled($thumb, $source, 0, 0, $x, $y, $thumb_width, $thumb_height, $width, $height);
    // save the resized copy
    switch($type) {
    case 1:
    if (function_exists('imagegif'))  {
    $success[] = imagegif($thumb, THUMBS_DIR.$newname.'.gif');
    $photoname = $newname.'.gif';
    else {
    $success[] = imagejpeg($thumb, THUMBS_DIR.$newname.'.jpg',50);
    $photoname = $newname.'.jpg';
    break;
    case 2:
    $success[] = imagejpeg($thumb, THUMBS_DIR.$newname.'.jpg', 100);
    $photoname = $newname.'.jpg';
    break;
    case 3:
    $success[] = imagepng($thumb, THUMBS_DIR.$newname.'.png');
    $photoname = $newname.'.png';
    if ($success) {
    $result[] = "Upload sucessful";
    else {
    $result[] = 'Problem uploading image, please try again or contact us for further assistance';
    // remove the image resources from memory
    imagedestroy($source);
    imagedestroy($thumb);
    ?>
    I hope i´ve supplied enough information and look forward to receiving any help or advise in this matter.

    Use double quotes here:
    $newname = str_replace ('name', '$username_$number', $name);
    Change it to this:
    $newname = str_replace ('name', "$username_$number", $name);

  • S3 backup can't upload files with apostrophe​s in the name

    s3 backup doesn't seem to be able to upload any file with an apostrophe in the name.  I see a load of "Unable to upload 'foo bar's.file' to Amazon S3" warnings in the event log.  The log is littered with file names that contain an apostrope.  This seems to be the thing that stands out in common with all of the failed transfers.  Is there some way to workaround the problem besides renaming all files containing apostropes?
    It seems like an easy fix to properly escape single quotes in the name for upload though, but I suppose that I'll need a firmware fix for a change like that.

     Hello spitzcor
    Have you checked your Amazon S3 account to see if the files have actually uploaded to the bucket or if they did indeed fail to upload?
    I also recommend that you contact support to have an incident created.  There is a hotfix for 4.1.108 that updates the Amazon S3 applications API version and might help with what you are experiencing, although it is intended for a seperate Amazon S3 issue.
    LenovoEMC Contact Information is region specific. Please select the correct link then access the Contact Us at the top right:
    US and Canada: https://lenovo-na-en.custhelp.com/
    Latin America and Mexico: https://lenovo-la-es.custhelp.com/
    EU: https://lenovo-eu-en.custhelp.com/
    India/Asia Pacific: https://lenovo-ap-en.custhelp.com/
    http://support.lenovoemc.com/

  • Rename a File in a SharePoint document library through Client object model

    Hi,
    How  to Rename a File in a SharePoint document library through Client object model?
    Thanks
    Poomani Sankaran

    Hi,
    According to your description, you want to rename file in the document library using SharePoint Client Object Model.
    Here is a code snippet works well in my environment for your reference:
    static void Main(string[] args)
    string url = "http://sp2013sps/sites/test/";
    ClientContext clientContext = new ClientContext(url);
    Microsoft.SharePoint.Client.List spList = clientContext.Web.Lists.GetByTitle("Documents");
    clientContext.Load(spList);
    clientContext.ExecuteQuery();
    if (spList != null && spList.ItemCount > 0)
    Microsoft.SharePoint.Client.CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml =@"<View> <Query> <Where><Eq><FieldRef Name='LinkFilenameNoMenu' /><Value Type='Computed'>New Microsoft Word Document.docx </Value></Eq></Where> </Query> <ViewFields><FieldRef Name='Title' /></ViewFields> </View>";
    ListItemCollection listItems = spList.GetItems(camlQuery);
    clientContext.Load(listItems);
    clientContext.ExecuteQuery();
    listItems[0]["Title"] = "word.docx";
    listItems[0]["FileLeafRef"] = "word.docx";
    listItems[0].Update();
    clientContext.ExecuteQuery();
    More information about SharePoint Client Object Model:
    http://msdn.microsoft.com/en-us/library/office/ee537247(v=office.14).aspx
    http://www.codeproject.com/Articles/399156/SharePoint-Client-Object-Model-Introduction
    http://www.learningsharepoint.com/2010/07/12/programmatically-upload-document-using-client-object-model-sharepoint-2010/
    Best regards

  • WEBUTIL: Uploading files with arabic file names to a BLOB column in DB

    Hi
    I'm using webutil (webutil_file_transfer.client_to_db_with_progress)
    to store files in a blob field in a 9i database, I'm doing that using forms 9i.
    I'm successful in storing files with English names in the database, however if I want to store a file with an arabic file name , it doesn't get uploaded and the BLOB is empty. Is there any work around to solve this problem.
    I tried renaming the arabic file name to an english file name then uploading which was fine, but when I try to rename the file back to arabic, this step fails. I asked a friend and he said that although I'm renaming the file back to arabic in a statment after uploading, that doesn't mean that the upload has finished, i.e the file is still locked for upload that's why I can't rename it back to arabic, I can't rename it even if I try that directly from the operating system.
    can anyone help in solving this problem!!
    Regards

    Hi
    I'm using webutil (webutil_file_transfer.client_to_db_with_progress)
    to store files in a blob field in a 9i database, I'm doing that using forms 9i.
    I'm successful in storing files with English names in the database, however if I want to store a file with an arabic file name , it doesn't get uploaded and the BLOB is empty. Is there any work around to solve this problem.
    I tried renaming the arabic file name to an english file name then uploading which was fine, but when I try to rename the file back to arabic, this step fails. I asked a friend and he said that although I'm renaming the file back to arabic in a statment after uploading, that doesn't mean that the upload has finished, i.e the file is still locked for upload that's why I can't rename it back to arabic, I can't rename it even if I try that directly from the operating system.
    can anyone help in solving this problem!!
    Regards

  • Rename, upload, and check-in

    I am trying to find the correct sequence of code (using the IfsFileSystem API) which will check-out a versioned file, upload a renamed file, and check-it in resulting in the following versions:
    Version 1. Original Filename.doc
    Version 2. Renamed Filename.doc
    The following code used to work in IFS 1.083.
    IfsFileSystem.rename()
    IfsFileSystem.checkOut()
    IfsFileSystem.putDocument()
    IfsFileSystem.checkIn()
    However, this same code used against IFS 1.1 now results in the following versions:
    Version 1. Renamed Filename.doc
    Version 2. Renamed Filename.doc
    I've tried re-ordering this sequence of code, but I receive a IFS-68005 error when attempting a putDocument before renaming the file.
    Can anyone help?
    Thanks
    Steve Probst
    null

    I think I've answered my own question. The following seems to work in IFS 1.1:
    IfsFileSystem.checkOut()
    /* use the OLD (Original Filename.doc
    )filename here */
    IfsFileSystem.putDocument()
    /* rename to Renamed Filename.doc */
    IfsFileSystem.rename()
    IfsFileSystem.checkIn()
    This will result in the desired:
    Version 1. Original Filename.doc
    Version 2. Renamed Filename.doc
    null

  • Batch Rename Raw Files After Import?

    Can you batch rename raw files after you import, so that the file name changes in Aperture and on the hard drive? I want to be able to edit images, and then rename only the keepers. This has been asked before here, but I could not find an answer.
    Thanks!

    File -> Export, Kind: Original
    When you import a Raw to iPhoto it automatically creates a jepg preview of the file. Why? Because you cannot do anything with a Raw: you cannot print it, use it a slideshow and so on. However, with this preview you can work with the photo immediately.
    You can, however, also process the Raw in iPhoto simply by editing it. The Raw processing engine in iPhoto the same one used in Aperture, but with less fine control. (Think of the differences between Word and TextEdit, iMovie and Final Cut). The output from the processing then replaces the preview. You can choose to save your output as either jpeg or tiff in the iPhoto Preferences.
    When you are processing Raw in iPhoto you will see the Raw badge on the bottom of the iPhoto Window
    Uploaded with plasq's Skitch!
    Note: After you have processed a Raw, subsequent edits to the photo are carried out on the processed jpeg (or tiff) not the Raw. If you want to go back to the original then you need to use the Photos -> Reprocess Raw command.
    Aperture works in an entirely different way. What are you trying to do, exactly?
    Regards
    TD

  • Rename a File in Dreamweaver

    Hello,
    I have a page called index.htm. I want to rename this file in
    Dreamweaver to index_old.htm. However, when I do that DW starts
    automatically scanning my site to update all the links that link to
    that page. I don't want it to do that because I'm planning on
    creating a new index.htm. What can I do to stop DW from doing that?
    Thank You

    > So if I didn't have the check in/out enabled then it
    would ask me if I
    > want to update the links?
    Yes.
    > Why would DW disable that just because check in/out was
    enabled?
    Because the entire paradigm of operation changes when you
    enable CI/CO.
    When it's not enabled, your local site is the GOLD standard.
    DW knows that
    it can change all links to your files within the files there,
    because they
    are the latest version and can then be uploaded. When you
    enable CI/CO, the
    local site is merely relegated to scratch pad functionality,
    and the remote
    site becomes the GOLD standard. In order to change all the
    links to a
    renamed file, DW would have to GET ALL the files from the
    remote site first.
    Surely you wouldn't want it to do that.
    That's why.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "esuweb" <[email protected]> wrote in
    message
    news:enkauc$apn$[email protected]..
    > Ace,
    > So if I didn't have the check in/out enabled then it
    would ask me if I
    > want to update the links? Why would DW disable that just
    because check
    > in/out was enabled?
    >
    > Thanks for your help

  • UCCE / IPIVR : Error while uploading file. Please try again later.

    IPIVR version 8.5x
    Receive "Error while uploading file. Please try again later" 
    Renamed the script to a different name and still could not upload.   I am able to upload other scripts without any issue.   I did find the ICM subsystem in partial service.   If that was the issue I would think it would cause an issue with all the scripts.   The script does validate.   Not sure why at this point.

    Hi Aditya,
    Are you using  SharePoint 2010 or SharePoint 2013?
    Did this issue occur for all users or the special user?
    Please go to Central Administration->Manage service applications->User Profile service application->manage user profile, search and edit the user profile, then upload a picture for the user, compare the result.
    In addition, please check the log file to check more information about this issue.
    The path of the log file is:
    SharePoint 2010: C:\Program Files\Common Files\microsoft shared\Web Server Extensions\14\LOGS
    SharePoint 2013: C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\LOGS
    Best Regards,
    Wendy
    Wendy Li
    TechNet Community Support

Maybe you are looking for