Search the Community
Showing results for tags 'sessions and $_file'.
-
I am using a page to upload an image. Here are the code. This is working. My problem is when the user login and when there is session variables this is not working. please help. error is Notice: Undefined index: uploaded Main page <?php session_start(); if($_FILES['uploaded']['name']!== ''){ $target = "images/books/"; include("upload_image.php"); //Rename image $original_name=basename($_POST['uploaded']['name']); if($upload_file==1){ rename("images/books/$original_name","images/books/$book_id.jpg"); } ?> echo "<form action='' method='POST' enctype='multipart/form-data'><table cellpadding='2' cellspacing='2' border='0'>"; echo "<tr><td></td><td><input class='input-file uniform_on' type='file' name='uploaded' /></td>"; echo "</table></form>"; upload_image.php <?php $target = $target . basename($_POST['uploaded']['name']) ; $upload_file=0; $Err_count=0; if (filesize($_POST['uploaded']['tmp_name']) < 300000){ //300KB if(($_FILES['uploaded']['type'] == 'image/jpg') || ($_FILES['uploaded']['type'] == 'image/jpeg')){ if(is_uploaded_file($_POST['uploaded']['tmp_name'], $target)) { $upload_file=1; $Err_count=0; Info ("The file ". basename( $_POST['uploaded']['name']). " has been uploaded and renamed to relevant image file"); } else { Error ("Sorry, there was a problem uploading your file"); $Err_count=1; } } else{ $Err_count=2; Error ("Your file is not an image of jpg or jpeg"); } } else{ $Err_count=3; Error ("Your file is too large. Please upload less than 300KB"); } ?>