Jump to content
Larry Ullman's Book Forums

Chapter 19, Script 19.2 Rename() Doesn'T Work For E


Recommended Posts

Hi there,

 

Is there anyone having the same issue as mine or not that my uploaded file is not renamed in the database though I have tried several uploads?

 

I do not make any changes to the sample codes at all.

 

// Create a temporary file name:
        $temp = './uploads/' . md5($_FILES['image']['name']);

.

.

.

// rename image
            $id = mysqli_stmt_insert_id($stmt); // Get the print ID                
                
                rename ($temp, "./uploads/$id");

 

Your help will be appreciated.

Regards,

Ericp

Link to comment
Share on other sites

It's not renamed in the database or renamed on the file system? The rename() function only impacts the file system.

 

OK. I will take a look at them when the files—the images—are served by the public side of the site, as the book says 'you’ll soon see'.

 

Just a bit curious... as I thought that it's renamed in the database.

Link to comment
Share on other sites

Hi all,

 

One more thing about this script is that I tried to improve this script by adding the validation code to allow some certain file size and types as per the script 11.2 in the chapter 11 suggests- before moving them to the permanent destination, 'uploads' folder. It works well!

 

My concern is that should I add the else { $temp = NULL; } to the if (is_uploaded_file($_FILES['image']['tmp_name'])) {... or to the if ($_FILES['image']['error'] > 0) {...   ? because the code check the size errors before the type ones.

 

Rgds,

Link to comment
Share on other sites

 Share

×
×
  • Create New...