PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello All,
I am using the following code to upload file to server. I am having a strange problem that the file does not
upload the first time PHP is called from HTML form, when he browser is refreshed i.e. the script is executed again
the file gets uploaded to the desired location. Please help me solve my problem.
HTML Form:
<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = '../';
$uploadfile = $uploaddir . basename($_FILES['uploadedfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Does your script indicate that the file HAS been uploaded after the initial try? What about after the refresh? Seems like a strange problem.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
The only thing that I see wrong right off the bat is that you need to put quotation marks around METHOD and SIZE attributes in your HTML form. See below
scottayy wrote:Does your script indicate that the file HAS been uploaded after the initial try? What about after the refresh? Seems like a strange problem.
yes it notifies for the first time that the file has been successfully uploaded and on refresh also it gives the same message. And thereafter if I refresh it gives me the message to notify that the file already exists.