Forum Moderators: coopster
if (is_uploaded_file($_FILES['image1']['tmp_name'])){
if (move_uploaded_file($_FILES['image1']['tmp_name'], "../uploads_golf/{$_FILES['image1']['name']}")) {
$problem = FALSE;
echo '<p align="center"><font color="red"><b>The file was uploaded</b></font></p>';
} else {
$problem = TRUE;
echo '<p>The file could not be moved because </p>';
$img_name1 = 'noimage.jpg' ;
}
$img_name1 = $_FILES['image1']['name'];
} else {
$img_name1 = 'noimage.jpg';
}
What I want to do is change the file name so when it is uploaded it is changed whether it be use of the rand command or not but i cannot seem to do it. Is there a way that you can do this and then have it also go into the mysql table as the same name for instance:-
I upload a file in the form called me.jpeg
It goes throught the mothions but changes to 4093490939.jpg or something like that and then uploads the file as that and inserts into the MYSQL table as this.
Can this be done or not! I am not sure I have read up and this forum is the most helpful by a mile so please plese help
your problem can be solved by simply naming the move-to filename with a function you're already using:
move_uploaded_file($_FILES['image1']['tmp_name'], "../uploads_golf/{$_FILES['image1']['name']}") just modify the second parameter and replace the name with the name you want to use (let's say it's the value of
$imagefilename):
move_uploaded_file($_FILES['image1']['tmp_name'], "../uploads_golf/$imagefilname")
i think this should solve one part of your problem. the other maybe you don't know how to name the new file, right? do you want to create a random name for it (rand) or do you want to have it bound to a databases entry primary key?