Jump to content

davidpc

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by davidpc

  1. I'm sorry. I have no idea what you mean. You are over my head. As I said, I have a very basic understanding. I have no idea how to handle a session or use $_SESSION array. And no idea how to use FILTER_SANITIZE_STRING. Most of what I posted here was given to me by a friend, but he had no idea how to get around my "problem"
  2. Ok. Here is what I have now. It works, but if 2 people upload before I get to it, they get mixed up. This is the main .html file. <html> <body> <form action="upload.php" method="post" enctype="multipart/form-data"> Select image to upload: <input type="file" name="fileToUpload" id="fileToUpload"> <input type="submit" value="Upload Image" name="submit"> </form> </body> </html> I have a php.ini and all it says is "file_uploads = On" with out brackets. Last is the .php file <?php $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); // Check if image file is a actual image or fake image if(isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } // Check if file already exists if (file_exists($target_file)) { echo "Sorry, file already exists."; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 500000) { echo "Sorry, your file is too large."; $uploadOk = 0; } // Allow certain file formats if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded."; } else { echo "Sorry, there was an error uploading your file."; } } ?> In the second line, it tells where to place the files, the uploads directory. I need a way that 2 or more people can upload without things getting jumbled up
  3. Ok. You guys are going to have to help me here. Show me the code that will do that. I am not familair with how to time stamp. And as I said I know html only by what I have learned and have never really worked with php as it seems more involved
  4. Number 1. I am not versed well in html. If I see something on a website I don't understand, I will look at the code to see how it is done. Never took classes nor read books. I have learned on notepad. Years ago I tried Front Page and was confused and hampered more by it, so I went back to Notepad, or since I use Linux it is text editor same thing. I think it helps me understand and learn more than having software do the work for me....
  5. On my website, users can upload images to me to post. Sometimes I could get several people to upload before I can get to them. I need a uploader that will keep them seperate. I have one that I have been working with, but if 2 people upload, files go into the same folder and are mixed up. Any ideas? I am attaching what I have been working with. I am not versed in html code at all as it has all been learned from trial and error...more error than trial <html> <head> <title>Upload</title> </head> <body background="background.jpg"> <br><br><br> <p align="center"> <img src="header.jpg" height="157" width="799"> <br><br><br><br><br><br> <form action="upload.php" method="post" enctype="multipart/form-data"> <font color="white"> <p align="center"> Select image to upload: <input type="file" name="fileToUpload" id="fileToUpload"> <input type="submit" value="Upload Image" name="submit"> </form> </body> </html>
×
×
  • Create New...