All of the sudden I keep getting these error messages with this script. This script has worked for so long so I do not know why it doesnt anymore. I also get the invalied file type else statement when I upload a perfectly good file. I am really lost with this.
<?
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
$extension = getExtension($_FILES['upload']['name']);
$extension = strtolower($extension);
session_start();
$username = $_SESSION['username'];
if ($_SESSION['logged']!==true) {
header('location:loginfailed.php');
}
else {
$target = 'photos/'.$username;
$target = $target ."/". basename($_FILES['upload']['name']) ;
$_SESSION['extension']=$extension;
if (($extension == "jpg") || ($extension == "gif") || ($extension == "jpeg") || ($extension == "png"))
{
if ($_FILES['upload']['size'] < 2000000)
{
if(move_uploaded_file($_FILES['upload']['tmp_name'], $target))
{
$name = $_FILES['upload']['name'];
$_SESSION['name'] = $name;
$imageSize = $_FILES['upload']['size'];
$_SESSION['size'] = $imageSize;
$type = $_FILES['upload']['type'];
$_SESSION['type'] = $type;
$_SESSION['view'] = 1;
header('location:successful.php');
}
else
{ header('location:invalidMove.php'); }
}
else
{header('location:invaliedSize.php');}
}
else
{ header('location:invalidType.php');}
?>
With these errors....
Warning: move_uploaded_file(photos/anna/babybbybybybyybyyy.jpg): failed to open stream: No such file or directory in /home/photocoo/public_html/uploadSuccess.php on line 31
Warning: move_uploaded_file(): Unable to move '/var/tmp/phpj4nPiv' to 'photos/anna/babybbybybybyybyyy.jpg' in /home/photocoo/public_html/uploadSuccess.php on line 31
Warning: Cannot modify header information - headers already sent by (output started at /home/photocoo/public_html/uploadSuccess.php:31) in /home/photocoo/public_html/uploadSuccess.php on line 46