Image upload xampp


#1

hi i have a php script for upload images that’s working on my website but if i work on the local host it dosen’t work.The script tell me success but the uploads folder is empty. all is store in htdocs.
i hope somebody can help me.
thank you!!!

`<?php

if (isset($_POST[‘submit’])) {
$file = $_FILES[“file”];

$fileName = $_FILES["file"]["name"];
$fileTmpName = $_FILES["file"]["tmp_name"];
$fileSize = $_FILES["file"]["size"];
$fileError = $_FILES["file"]["error"];
$fileType = $_FILES["file"]["type"];

$fileExt = explode('.', $fileName);
$fileActualExt = strtolower(end($fileExt));

$allowed = array('jpg','jpeg','png','gif' );

if (in_array($fileActualExt, $allowed)) {
    if ($fileError === 0) {
        if ($fileSize < 500000) {
            $fileNameNew = uniqid('', true).".".$fileActualExt;
            $fileDestination = 'uploads/'.$fileNameNew;
            move_uploaded_file($fileTmpName, $fileDestination);
            header("Location: ../index.php?uploadsuccess");
        } else {
            echo "Your file is too big!";
        }
    } else {
        echo "There was an error uploading your file!";
    }
} else {
    echo "You ca not upload files of this type!";
}

}`


#2

Well, my guess is that you either do not have the folder writable in apache or more likely is that you need to point to the real folder not the fake one set up on the website. Instead of “uploads/”.$fileNameNew; you would need something like:

realpath(dirname(__FILE__) . '/../uploads/') . '/' . $fileNameNew;

Not sure. Or, you might need to put in the actual folder like D:\wamp\www\my-site-name\uploads\ . $filename…

Live folder structure is often not the same as with a virtual system.


#3

First, does that folder exist in your local version? If not that is a problem.

You can test for writability,
http://php.net/manual/en/function.is-writable.php


#4

Thank’s for your help!!!


#5

Thank’ for your help!!!