Jump to content

AmericanAlien

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Everything posted by AmericanAlien

  1. Trust me, you have helped me a ton. I understand the loop route you speak of. I have tried that from the start, but maybe my paths are not inputted correctly. Maybe I can do what I do with my forms and have the info (pics)inputted into a form type php document. I think that may work, I have not tried that yet. Your code was the first code that actually worked, and I think I can use that and use my form method and integrate them or mesh them together. At least I hope so. Again, thanks for your tremendous help, absolutely appreciated!
  2. The code is working AWESOMELY! The actually shows up this time. I appreciate your hard work. One thing. This is a permanent page, the pics do not stay in that page so others can view it. Is this not possible? What I mean is, is there a way to have each picture that is upload to stay on the webpage in the order uploaded and others can view this page as well?
  3. Thanks for the help! I had to go in another direction for now. A quick question, how is that code displaying the pic in a new page? I see it sources the pic, but I do not see how it takes the pic and places it into an html or even php page in a type of gallery.
  4. Ok, from what I am reading, I do need the header, unless I am interpreting it incorrectly. How would I achieve this type of result?
  5. header("Location:display.php?imageName=".$file_name ); exit(); So this line is not needed? However, why is the display.php not showing up? I am not following that. So, if I get rid of that header, what route do I use to get location?
  6. I tried the code again and it still errors. Are you getting a page with the image (from display.php?) because I do not and I just get the confirmation page, and when I go to the display.php, it shows me nothing but a broken image. Attached is the error (error 77 is still the same line of code.) header("Location:display.php?imageName=".$file_name ); exit(); I have used your code exactly and just used the basics. [attachment deleted by admin]
  7. That is interesting, I didn't think about echo $row, This would need the database built, no? Or is this doing its own row built from the file on the server? That might be the way to go. I will try to see if I can do this. BLOB is definitely a weak point for me, this looks like very good practice for me.
  8. The database option might be the only way to go. I was really hoping I could just pull the images from my upload file (after the upload) and then have them displayed in a new page via php.
  9. I figured, I just wanted to be safe, but I still get the same error, and I still do not have any images on the display.php page. I am not sure what is going on. I have tried to get this down.
  10. Place this on top of which portion of the code? The main code? I will try that. Thanks for help!
  11. I am not understanding your question. Below is the code you suggested. You said to add the code (error 183) below the "successfully uploaded!" portion. If this isn't what you mean, I really do not understand what you mean.
  12. As from my previous post line 183 is: header("Location:".$config_basedir ."display.php?imageName=".$file_name ); exit();
  13. I want the images displayed in another webpage and for it to go directly to that page after the upload. The file it pulls the image from is uploads. As you can see from the code, it is trying to pull from that folder.
  14. My code is as follows: <?php /* This script can send an email and/or make an entry in a log file There are two variables below - one for an email address and one for a log file Set both variables to the values you want to use If you do not want either an email or log entry, comment out the respective line For example, if you do not want an email sent, put a // in front of the $emailAddress line - same for the $logFile line */ $logFile = $_SERVER['DOCUMENT_ROOT'].'/upload.log'; // full path to your log file $emailaddress = "email@gmail.com"; $home_page = "index.html"; // used for a link to return $uploaddir = "uploads/"; // the directory where files are to be uploaded - include the trailing slash $fileTypeArray = array(".jpg",".gif",".txt"); // enter in all lower case, the script will handle a match with upper case $maxSize = 500000; // maximum file size that can be uploaded - in bytes $maxFileSpace = 50000000; // maximum space that can be used by files matching the $fileTypeArray array in the upload directory - in bytes putenv('TZ=EST5EDT'); // eastern time // change nothing below this line $maxDisplay = $maxSize / 1000; ?> <html><head></head><body> <div style="text-align: center; margin: 100px auto; border: 1px black solid; width:400px;"> <?php // print_r($_FILES); // can be used for debugging $file_name = $_FILES['file']['name']; $file_size = $_FILES['file']['size']; $file_tmp_name = $_FILES['file']['tmp_name']; if (!empty($file_name)) { unset($error); echo "<br>File Name: $file_name<br><br>"; echo "File Size: $file_size bytes<br><br>"; // file size test if ($file_size == 0 ) $error .= "<span style='color: red;'>Invalid file</span><br>"; if ($file_size > $maxSize ) $error .= "<span style='color: red;'>Your file exceeds $maxDisplay K.</span><br>"; // file type test if (!in_array(strtolower(strrchr($file_name,'.')),$fileTypeArray) ) $error .= "<span style='color: red;'>Your file is not a valid file type.</span><br>"; // max directory size test foreach(scandir($uploaddir) as $file_select) if (in_array(strtolower(strstr($file_select,'.')),$fileTypeArray)) $total_size = $total_size + filesize($uploaddir.$file_select); if (($total_size + $file_size) >= $maxFileSpace) $error .= "<span style='color: red;'>Total file space limits have been exceeded.</span><br>"; // scrub characters in the file name $file_name = stripslashes($file_name); $file_name = preg_replace("#[ ]#","_",$file_name); // change spaces to underscore $file_name = preg_replace('#[^()\.\-,\w]#','_',$file_name); //only parenthesis, underscore, letters, numbers, comma, hyphen, period - others to underscore $file_name = preg_replace('#(_)+#','_',$file_name); //eliminate duplicate underscore // check for file already exists if (file_exists($uploaddir.$file_name)) $error .= "<span style='color: red;'>File already exists.</span><br>"; // if all is valid, do the upload if (empty($error)) { if (move_uploaded_file($file_tmp_name,$uploaddir.$file_name)) { chmod($uploaddir.$file_name,0644); echo "<span style='color: green;'>Your file was successfully uploaded!</span>"; if (isset($emailAddress)) { $message = $file_name . " was uploaded by".$_SERVER['REMOTE_ADDR']."at".date('Y-m-d H:i:s'); mail($emailaddress,"You have a file upload",$message,"From: Website <>"); } if (isset($logFile)) { $logData = $file_name."||".$_SERVER['REMOTE_ADDR']."||".date('Y-m-d H:i:s')."\r\n"; @file_put_contents($logFile,$logData,FILE_APPEND|LOCK_EX); } } else { echo "<span style='color: red;'>Your file could not be uploaded.</span>"; } } echo "$error<hr>"; } ?> <p>Upload a <span style="color: blue;"> <?php foreach($fileTypeArray as $fileType) echo $fileType; ?> </span> file to our server<br> Maximum file size is <?php echo $maxDisplay; ?>K</p> <form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post" enctype="multipart/form-data"> File: <input type="file" name="file" style="width: 250px;"><br> <input type="submit" name="submit" value="Upload File"></form> <a href="<?php echo $home_page; ?>">Return to the Home Page</a> and the display.php is: <?php // please validate the input $uploaddir = "uploads/"; // the directory where files are to be uploaded - include the trailing slash $file_name = $_GET['imageName']; echo "<img src='$uploaddir.$file_name' />"; ?> I get this error: Warning: Cannot modify header information - headers already sent by (output started at /homepages/1/d225596241/htdocs/enter.php:6) in /homepages/1/d225596241/htdocs/enter.php on line 183 Line 183 is: header("Location:".$config_basedir ."display.php?imageName=".$file_name ); exit(); The pic shows up after the upload, but it does not go to the display.php page nor does it automatically go to that page. Also, after the upload and the pic shows up the error I provided is show below. Any ideas?
  15. You have been a tremendous help. I just cannot get it to work, I must be missing something, or a path or a pattern. I will keep trying. I know it is late, but hopefully I can get it to work soon.
  16. Yes, that is what I am trying to achieve. I am just not succeeding at it.
  17. Well, I have to admit, that is the closest I have gotten. The pic does show up. THANK YOU! However, I would like it to show up to a new webpage and stay there. Something like: <form method="post" action="gallery.php"> Would something like this work? Have the php shoot to that upload gallery and then have the gallery display with the new image?
  18. Hello all, I am having an issue. I have read many articles and help forums, but I cannot find a specific way to help me. My issue is this. I have a php upload form for visitors to upload an image. Now, I would like to know how to get the uploaded images to show up after the upload. Someone suggested to me to call the images. However, I am not sure how to do this. Below is the script for the image upload, which works great for uploading. <?php /* This script can send an email and/or make an entry in a log file There are two variables below - one for an email address and one for a log file Set both variables to the values you want to use If you do not want either an email or log entry, comment out the respective line For example, if you do not want an email sent, put a // in front of the $emailAddress line - same for the $logFile line */ $logFile = $_SERVER['DOCUMENT_ROOT'].'/upload.log'; // full path to your log file $emailaddress = "email@gmail.com"; $home_page = "index.html"; // used for a link to return $uploaddir = "uploads/"; // the directory where files are to be uploaded - include the trailing slash $fileTypeArray = array(".jpg",".gif",".txt"); // enter in all lower case, the script will handle a match with upper case $maxSize = 500000; // maximum file size that can be uploaded - in bytes $maxFileSpace = 50000000; // maximum space that can be used by files matching the $fileTypeArray array in the upload directory - in bytes putenv('TZ=EST5EDT'); // eastern time // change nothing below this line $maxDisplay = $maxSize / 1000; ?> <html><head></head><body> <div style="text-align: center; margin: 100px auto; border: 1px black solid; width:400px;"> <?php // print_r($_FILES); // can be used for debugging $file_name = $_FILES['file']['name']; $file_size = $_FILES['file']['size']; $file_tmp_name = $_FILES['file']['tmp_name']; if (!empty($file_name)) { unset($error); echo "<br>File Name: $file_name<br><br>"; echo "File Size: $file_size bytes<br><br>"; // file size test if ($file_size == 0 ) $error .= "<span style='color: red;'>Invalid file</span><br>"; if ($file_size > $maxSize ) $error .= "<span style='color: red;'>Your file exceeds $maxDisplay K.</span><br>"; // file type test if (!in_array(strtolower(strrchr($file_name,'.')),$fileTypeArray) ) $error .= "<span style='color: red;'>Your file is not a valid file type.</span><br>"; // max directory size test foreach(scandir($uploaddir) as $file_select) if (in_array(strtolower(strstr($file_select,'.')),$fileTypeArray)) $total_size = $total_size + filesize($uploaddir.$file_select); if (($total_size + $file_size) >= $maxFileSpace) $error .= "<span style='color: red;'>Total file space limits have been exceeded.</span><br>"; // scrub characters in the file name $file_name = stripslashes($file_name); $file_name = preg_replace("#[ ]#","_",$file_name); // change spaces to underscore $file_name = preg_replace('#[^()\.\-,\w]#','_',$file_name); //only parenthesis, underscore, letters, numbers, comma, hyphen, period - others to underscore $file_name = preg_replace('#(_)+#','_',$file_name); //eliminate duplicate underscore // check for file already exists if (file_exists($uploaddir.$file_name)) $error .= "<span style='color: red;'>File already exists.</span><br>"; // if all is valid, do the upload if (empty($error)) { if (move_uploaded_file($file_tmp_name,$uploaddir.$file_name)) { chmod($uploaddir.$file_name,0644); echo "<span style='color: green;'>Your file was successfully uploaded!</span>"; if (isset($emailAddress)) { $message = $file_name . " was uploaded by".$_SERVER['REMOTE_ADDR']."at".date('Y-m-d H:i:s'); mail($emailaddress,"You have a file upload",$message,"From: Website <>"); } if (isset($logFile)) { $logData = $file_name."||".$_SERVER['REMOTE_ADDR']."||".date('Y-m-d H:i:s')."\r\n"; @file_put_contents($logFile,$logData,FILE_APPEND|LOCK_EX); } } else { echo "<span style='color: red;'>Your file could not be uploaded.</span>"; } } echo "$error<hr>"; } ?> <p>Upload a <span style="color: blue;"> <?php foreach($fileTypeArray as $fileType) echo $fileType; ?> </span> file to our server<br> Maximum file size is <?php echo $maxDisplay; ?>K</p> <form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post" enctype="multipart/form-data"> File: <input type="file" name="file" style="width: 250px;"><br> <input type="submit" name="submit" value="Upload File"></form> <a href="<?php echo $home_page; ?>">Return to the Home Page</a> </div> What is the method or process to get the images to show up or to pull the images from the folder to a webpage?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.