Jump to content

Recommended Posts

Hello,

 

i'm trying to create some file upload which renames the files automatically, the renamed file name needs to be the value from another text field, example:

 

i have a file upload form, and a last name text input, after the file upload the file should be renamed to the value of the last name input.

 

i really don't know where to start here, can anyone give me some hint / advice?

 

Thanks.

Do you have any working code for the file upload process at all? What you are asking for would be a highly trivial task with working code, so I assume not. There are countless "PHP Upload" tutorials on the next. Go find one and create an upload page. You should be able to easily figure out the rename part since you have to name the file when you save it anyway. Post back with any problems you have.

 

If you just want someone to build it for you then you can post in the freelance forum.

move_uploaded_file

 

The line above "move_uploaded_file" get the name from the textbox named "last_name".

<?php
$uploads_dir = '/uploads';
foreach ($_FILES["pictures"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
        $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
        $name = $_POST['last_name'];
        move_uploaded_file($tmp_name, "$uploads_dir/$name");
    }
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.