Page 1 of 1

Need Help For File Uploading!!

Posted: Wed Jun 14, 2006 2:50 am
by yumico23
Hi,

Can anyone advise me on file upload or copying to internal web-application?

I have internal office leave management system for staff to do up their leaves.
Problem is I can't perform a file upload.
I browse any file from my local server and upload it to our LMS webserver and couldn't work.
I tried both --> move_uploaded_file and copy function but couldnt work still.

Is there any other functions that I could try?
Currently the folder permission is drwxr-xr-x
Owner: Root
Group: Root

Please advise..thank you so much!

Posted: Wed Jun 14, 2006 3:40 am
by JayBird
Show your code

The Codes

Posted: Wed Jun 14, 2006 4:17 am
by yumico23
Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

$numoffile = 5;  
 // $file_dir  = "/var/www/html/gsy/office/doculms/"; to web intranet
//  $file_dir  = "./doculms/"; to web intranet
//$file_dir  = "/home/gsyglobal/htdocs/uploads/"; to web internet


  if ($_POST) {  
    for ($i=0;$i<$numoffile;$i++) {  
      if (trim($_FILES['myfiles']['name'][$i])!="") {  
        $newfile = $file_dir.$_FILES['myfiles']['name'][$i];  
		echo "Nwe File:". $newfile;
        move_uploaded_file($_FILES['myfiles']['tmp_name'][$i], $newfile);  
        $j++;  
      }  
    }  
  }  
  if (isset($j)&&$j>0) print "Your file(s) has been uploaded.<br>";  
  print "<form method='post' enctype='multipart/form-data'>";  
  for($i=0;$i<$numoffile;$i++) {  
    print "<input type='file' name='myfiles[]' size='30'><br>";  
  }  
  print "<input type='submit' name='action' value='Upload'>";  
  print "</form>";

Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Jun 14, 2006 4:19 am
by JayBird
Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Jun 14, 2006 5:11 am
by yumico23
Hi, ya ok noted! thank you

Posted: Wed Jun 14, 2006 10:12 pm
by yumico23
Hi,

I have also added this cmod function but it returned fail.
Can advise me on this? thank you

Code: Select all

$result  =  move_uploaded_file($temp_name, $file_path); 
  if (!chmod($file_path,0777)) 
       $message = "change permission to 777 failed."; 
  else 
    $message = ($result)?"$file_name uploaded successfully." : 
               "Somthing is wrong with uploading a file."; 
  return $message; 
}
Yuli

Posted: Thu Jun 15, 2006 3:39 am
by JayBird
Read the manual.

http://uk2.php.net/manual/en/features.file-upload.php

You need to throw errors to see what is failing