Jump to content

Upload and rename a photo "number1.jpg"


Guest dancingbear
 Share

Recommended Posts

Guest dancingbear

I've tried several form programs with upload functions, but can't seem to get this simple function down.I want an upload button on an index.phpThe submit uploads the image, and renames it "number1.jpgReturn to the index page.Seems so simple a cave man could do it, but I can't find any of those around.any shove in the right direction would be appreciated.eb

Link to comment
Share on other sites

You just want to always name the image "number1.jpg", every time? You should be able to find plenty of file upload examples, just substitute "number1.jpg" into the part where you save the file.Here's a file upload reference and some example code:http://www.php.net/manual/en/features.file-upload.php

$uploaddir = '/var/www/uploads/';$uploadfile = $uploaddir . "number1.jpg";echo '<pre>';if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {   echo "File is valid, and was successfully uploaded.\n";} else {   echo "Possible file upload attack!\n";}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...