zeusthegreat Posted March 29, 2011 Report Posted March 29, 2011 html> <body> <form action="Picture_page.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> called form_new.php <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["images_uploads"]; } } else { echo "Invalid file"; } ?> called upload_file.php <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 200000000)) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["images_uploads"]; } } else { echo "Invalid file"; } ?> called restriction_upload.php <?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 2000000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["picture_page_name"] . "<br />"; if (file_exists("upload" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["picture_page_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload_buttom/images_uploads" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?> called saving_upload.php this is what i get back from browser Upload: 1a81df52844236.gif Type: image/gif Size: 8.619140625 Kb Notice: Undefined index: images_upload in C:\wamp\www\upload_button\Picture_page.php on line 11 Stored in: now i have customized the stored in to a folder called image_uploads thought i was doing write but not sure now and i can only get the details of upload and not the picy, i have actually got it with a broken image before but forgot how i got there!!!! basically i want picys and word docs to be uploaded by public and for the pictures to go to a certain folder and then show on a specific page, password protected would be nice also. thanks anybody for any help!!!! Quote
falkencreative Posted March 29, 2011 Report Posted March 29, 2011 What's on page 11 of Picture_page.php (can you post the code)? Seems like you should focus on fixing this PHP error before debugging the rest of the code. Quote
zeusthegreat Posted March 29, 2011 Author Report Posted March 29, 2011 THIS IS PICTURE_PAGE.PHP <style type="text/css"> body { background-color: #FF0; } </style> <div> <?php echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["images_upload"]; // LINE 11 ?> </div> Quote
falkencreative Posted March 30, 2011 Report Posted March 30, 2011 So what is the process you are following? You seem to have a large number of PHP files, and I'm not sure how they work with each other. form_new.php upload_file.php restriction_upload.php saving_upload.php picture_page.php If I understand things correctly, you first load "form_new.php", submit the form, and then the form's action attribute sends the user to picture_page.php? I would think that you would need to upload the file using saving_upload.php -- neither form_new.php nor picture_page.php include code to upload images. Once the image is uploaded, you would need to save the path to the image you uploaded, and use that path to display the image. Are you following a tutorial for this? There are loads of basic tutorials that would probably help you -- just google search for "php image upload tutorial" or similar. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.