Hi,
Im trying to upload images to a server but i cant get the php code to work. I have pretty much copied the code word for word from a tutorial - can any of you tel me why this is?
---------------------------------------------------------------------------------------------------
<?php
if (getimagesize($_FILES['file']['tmp_name']) && $_FILES['file']['error'] == UPLOAD_ERR_OK)
{
$currentdir=getcwd();
move_uploaded_file($_FILES['file']['tmp_name'],
$currentdir . $_FILES['file']['name']);
echo ("<h1>Well Done</h1>");
}
echo ("<form action='{$_SERVER['PHP_SELF']}' method='post' enctype='multipart/form-data'>
<label for='file'>Image:</label>
<input type='file' name='file' id='file' class = 'contactfield'/>
<input type='submit' class = 'submit' value='Create This Entry!' />
</form>
?>
Help with uploading files
Moderator: General Moderators
Re: Help with uploading files
You have a (" with the echo that starts the form but no ") to end it.
Re: Help with uploading files
thanks for the quick response!
Seems i omitted the end of the echo from my copy and paste.
To elaborate on the issue the page loads fine - you can attempt to upload the file and then the message 'Well done' gets printed on screen when you submit the form but the actual file hasn't been uploaded. What possibly can be the issue have been through countless tutorials.
Seems i omitted the end of the echo from my copy and paste.
To elaborate on the issue the page loads fine - you can attempt to upload the file and then the message 'Well done' gets printed on screen when you submit the form but the actual file hasn't been uploaded. What possibly can be the issue have been through countless tutorials.
Re: Help with uploading files
$FileName=$UploadPath."upload/info_information/".$picture;
$file = $_FILES['file']['tmp_name'];
if(copy($file,$FileName))
{
unlink($file);
}
$file = $_FILES['file']['tmp_name'];
if(copy($file,$FileName))
{
unlink($file);
}
Re: Help with uploading files
Please use [ code = php ] tags guys.
Re: Help with uploading files
$currentdir needs to be writable by everyone. In 'Nix that means it needs permissions 0777.
Go into your php.ini file, find the error_reporting setting, and change it to E_ALL. Then find display_errors and turn that "on". Restart your server.
This way you'll see any error messages PHP gives.
Go into your php.ini file, find the error_reporting setting, and change it to E_ALL. Then find display_errors and turn that "on". Restart your server.
This way you'll see any error messages PHP gives.