I've setup a php script which produces a directory and uploads personal files to that particular directory. My problem is the fact that after i make use of the script to produce your directory, the file won't upload entirely. I went the identical script on the different host and also the upload process works all right. Plus, basically by hand produce the upload directory and apply chmod 777 via ftp then your transfer works all right. Could there be some kind of an environment using the host company that should be changed to permit the function to operate perfect?

This is actually the upload form:

<form action="/uploadFile.php" method="publish"


<label for="img_preview">Preview Image:</label>

<input type="file" title="img_preview" id="img_preview" />

<br />

<input type="hidden" title="id" value="newDirectory" />

<input type="submit" title="submit" value="Upload Flyer" />


Here's my PHP script (uploadFile.php):

$thisdir = getcwd()

$new_dir = $_Publish['id']

$full_dir = $thisdir . "/upload/" . $new_dir

function chk_dir($full_dir)  else 


chmod($full_dir, 0777)



//upload image

if ($_FILES["file"]["error"] > )




  //set image limitations



if ((($_FILES["img_preview"]["type"] == "image/presen")

 ($_FILES["img_preview"]["type"] == "image/jpeg")

 ($_FILES["img_preview"]["type"] == "image/pjpeg"))

&lifier&lifier ($_FILES["img_preview"]["size"] < 80000))

  digital or presen)...<br>

Also, check to         make     sure the filesize is under 8MB" .          $_FILES["img_preview"]["error"] .     "<br />"


is available("upload/". $new_dir ."/". $_FILES["img_preview"]["title"]))

  appears that " . $_FILES["img_preview"]["title"] . " already is available."




  "upload/" . $_Publish['id'] . "/" . $_FILES["img_preview"]["title"])

  echo "image file has moved effectively!"







Also, after i run the script no errors are created and also the file echos "image file has moved effectively!" however after i look for the file within the new location it's totally void. Appreciate your time and effort within this problem.

To begin with, your script includes a security hole. Never use passed $_Publish data to produce system sites. And not use 0777 for anything.

The move_submitted_file() returns false on the failure and also you would get your ability to succeed message even when it unsuccessful (inside your code)

Switch on display_errors and error logging and check out again.

you've used move_submitted_file() individually. Whether it returns false then also sucsess message is going to be printed.


if ( move_submitted_file($_FILES["img_preview"]["tmp_title"],

  "upload/" . $_Publish['id'] . "/" . $_FILES["img_preview"]["title"])) else

After you will get what's the primary problem. Also employ debugging point by print_r($_FILES) before move_submitted_file().

It isn't really the response to your question, but nonetheless it's worth your attention, I really hope. Don't depend on the kind of the file sent via $_FILES, case the mime-type sent through the browser so far as I recall, it may be easily compromized. Use getimagesize() function to obtain true image type in addition to height/width.

Same applies to the origin file title, but that should not pose a burglar hole.