gmonkey
03-14-2004, 02:53 PM
Hi
I have found a really simple upload script on this forum to my relief, (thanks to who wrote it), here it is below:
<form enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="2048000">
File: <input name="userfile" type="file" /><br />
<input type="submit" value="Upload" />
</form>
<?php
if (@is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
copy($_FILES["userfile"]["tmp_name"], "image/" . $_FILES["userfile"]["name"]);
echo "<p>File uploaded successfully.</p>";
}
?>
I am trying to edit to so that it checks if the filename is equal to the variable $di which is picked up from the form on the previous page.
So something like
if userfile == $id.jpg then upload else
rename username to $id.jpg then upload
I am used to working with variables in scripts (im a newbie) so dont know how to assign the username to do a check?
Any ideas?
I have found a really simple upload script on this forum to my relief, (thanks to who wrote it), here it is below:
<form enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="2048000">
File: <input name="userfile" type="file" /><br />
<input type="submit" value="Upload" />
</form>
<?php
if (@is_uploaded_file($_FILES["userfile"]["tmp_name"])) {
copy($_FILES["userfile"]["tmp_name"], "image/" . $_FILES["userfile"]["name"]);
echo "<p>File uploaded successfully.</p>";
}
?>
I am trying to edit to so that it checks if the filename is equal to the variable $di which is picked up from the form on the previous page.
So something like
if userfile == $id.jpg then upload else
rename username to $id.jpg then upload
I am used to working with variables in scripts (im a newbie) so dont know how to assign the username to do a check?
Any ideas?