Page 1 of 1

[SOLVED] error in uploading zip files using php 5

Posted: Wed Nov 29, 2006 4:46 am
by ryuuka
i am having problems using the following upload script:

it uses 2 pages and a form(as is expected) the data is saved into
userfile

the first page is for submitting wich is working fine.
but the second file(the saving file) does generate a problem upon trying to save the file
to given directory. I will mark where i think the problem is occuring

the file i always try to upload is a zip file of 1kb
already tried to us enctype='application/zip'

submit page:

Code: Select all

//the url for this part is: http://www.myintranetsite.com/website/main.php
echo "<form action='upload.php' method='POST' enctype='multipart/form-data'> ";
echo "submit this file: <input type=file name='userfile'><br>";
echo "<input type=submit value=submit></form> <br>";
saving page:

Code: Select all

//the url for this part is: http://www.myintranetsite.com/website/upload.php
//this is for error generation wich gives me nothing
  error_reporting(E_ALL); 
  ini_set('display_errors', TRUE);
//it displays this
echo "script start <br> <br>";


 if(!empty($_FILES["userfile"])) 
 { 
// in the main site the upload dir is:  http://www.myintranetsite.com/website/upload
    $uploaddir = "/upload/" ;
    //copy the file to the permanent location 
    if (move_uploaded_file($_FILES["userfile"]["tmp_name"], $uploaddir . $_FILES["userfile"]["name"])) 
      {
        echo("file uploaded");
      } 
      else 
      {
        echo ("error!");
       }
 }
// i put this in to see if it could do the above if statement
// this line is what this script alwas shows
else {
        echo "ryuuka has created an error";
     }
it's driving me nuts because in all the ways that i think about it, it should work
but it doesn't.

any solutions/hints or pointers

Posted: Wed Nov 29, 2006 5:09 am
by a94060
i think the php parser may be looking for the directory /upload on the root of the drive. try provideing the full path to the folder.

Posted: Wed Nov 29, 2006 5:45 am
by dibyendrah
Are you doing this thing in linux ?
If yes, try changing the permission to 666 to that directory.

At a quick glance in your code, I think problem lies in the upload path. You have done

Code: Select all

$uploaddir = "/upload/" ;
If the directory lies on same path as of script then change the path to

Code: Select all

$uploaddir = "upload/" ;
Hope this will help you.

Posted: Wed Nov 29, 2006 6:17 am
by ryuuka
sorry no go
maybe it's something that needs to be changed in the php.ini file?

edit: found this in the phpinfo.php:
ALL_HTTP

HTTP_CONNECTION:Keep-Alive
HTTP_ACCEPT:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*

HTTP_ACCEPT_ENCODING:gzip, deflate
HTTP_ACCEPT_LANGUAGE:nl
HTTP_HOST:www.gispen.net
HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 1.1.4322) HTTP_UA_CPU:x86

Posted: Wed Nov 29, 2006 7:09 am
by ryuuka
it suddenly works now.

it appears this was the part that needed to be in the form.
Had this before why it suddenly works now i don't know

Code: Select all

enctype='multipart/form-data'

Posted: Wed Nov 29, 2006 8:54 am
by a94060
allright man,your welcome.