Hi I'm trying to rename images and get parse errors. the main isea can be found in the code below: <?php $name='m08'; $name=md5($name); $newname=$name.gif; echo $newname; rename(uploads/m08.gif,uploads/$newname); ?> PHP: how should the code be to work?
You're leaving off a bunch of necessary quotes from your string constants. <?php $name='m08'; $name=md5($name); $newname=$name . '.gif'; echo $newname; rename('uploads/m08.gif','uploads/'.$newname); ?> PHP:
thanks. how about this one: <? move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]); $newname=md5(time()); rename('uploads/'. $_FILES["file"]["name"]','uploads/'.'$newname); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; ?> PHP:
The line with rename has a syntax error. Remove the single quote from the last parameter '$newname so that it is just $newname. You can check the syntax of a script without actually running it by calling the following from the command line: php -l script_name.php Code (markup): Note that the parameter is lower-case "el", not the number one.
That was half the problem, there was also a single quote after $_FILES['...'] that shouldn't have been there. rename('uploads/' . $_FILES["file"]["name"], 'uploads/' . $newname); PHP: