Jump to content

kobsjohn

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by kobsjohn

  1. FYI turning off the magic quotes worked. Thanks for your help!
  2. I am on PHP 5.3.8 ans right now I am seeing magic_quotes_gpc as ON so this looks like the bug is my problem. I will see if I can get the person at my company who controls PHP to turn off the magic quotes or update the software and let you know if it fixes the issue. Thanks!
  3. File name showed up ok for Jellyfish.jpg in the developer tools on the param tab, but the uploaded file was ellyfish.jpg. ellyfish.jpg was also what showed up in the response tab. I also tried Chrome and got the exact same result. Params (1st couple lines only. Tab had over 6,000 lines of gibberish): Content-Type: multipart/form-data; boundary=---------------------------100932476831350Content-Length: 776013-----------------------------100932476831350Content-Disposition: form-data; name="fileToUpload"; filename="Jellyfish.jpg"Content-Type: image/jpeg Response: Array( [fileToUpload] => Array ( [name] => ellyfish.jpg [type] => image/jpeg [tmp_name] => C:xampptmpphp46.tmp [error] => 0 [size] => 775702 ))
  4. Here is what I got for uploading Chrysanthemum.jpg I am using Firefox.
  5. This is pretty much straight from the linked page with only a tweak to max file size. <?php$target_dir = "uploads/";$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);$uploadOk = 1;$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);// Check if image file is a actual image or fake imageif(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 existsif (file_exists($target_file)) { echo "Sorry, file already exists."; $uploadOk = 0;}// Check file sizeif ($_FILES["fileToUpload"]["size"] > 800000) { echo "Sorry, your file is too large."; $uploadOk = 0;}// Allow certain file formatsif($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 errorif ($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 ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; } else { echo "Sorry, there was an error uploading your file."; }}?> Here is a bare bones version I got the same results with: <?php$target_dir = "uploads/";$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);// if everything is ok, try to upload filemove_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file) ?> HTML code for reference: <!DOCTYPE html><html><body><form action="upload.php" method="post" enctype="multipart/form-data"> Select file to upload: <input type="file" name="fileToUpload" id="fileToUpload"> <input type="submit" value="Upload File" name="submit"></form></body></html>
  6. I am wanting to put together a simple file upload page for a spec system. I started with the tutorial shown on this site linked here to get a basic understanding of how to do this: http://www.w3schools.com/php/php_file_upload.asp The upload function appears to work properly outside of the fact that it cuts off the first character of every file name. For example the first file I tested this on was the Windows7 stock picture of penguins. This got uploaded as enguins.jpg. I have had the same issue with any file I try. I have searched for some other scripts and they all appear to be functionally the same on how the file is named. I am on PHP version 5.3.8. Does anyone know where this issue may be coming from? Since I haven't found any other posts about this or FAQs referring to it as a common issue I am assuming it must be related to how the version of PHP is set up, but do not know where to look.
×
×
  • Create New...