You are here: Re: file upload « PHP « IT news, forums, messages
Re: file upload

Posted by "Sergey" on 06/21/05 13:22

use $HTTP_POST_FILES for older php versions

""Han"" <han@fonedream.com> ΣΟΟΒέΙΜ/ΣΟΟΒέΙΜΑ Χ ΞΟΧΟΣΤΡΘ ΣΜΕΔΥΐέΕΕ:
news:0F.C5.25080.BEB96B24@pb1.pair.com...
> Hello,
>
> I'm having a problem with a file upload. The following works on one server
> I use : -
>
> ---------------------------------------------------------------------------
> function add_me(){
> global $filename;
> global $maxFileSize;
> global $yourdirectory;
>
> // put this in a file that is called by your webpage with a form
> // use the form file input type and call it 'file'
>
> $maxFileSize = 204800;
> $filename = $_FILES['file']['tmp_name'];
> echo "f is ".$filename;
>
> if (file_exists($filename))
> {
> // open the file
> $handle = fopen($filename, "r");
>
> // 1. read the file in line by line
> while (!feof($handle))
> {
> $buffer = fgets($handle, 4096);
>
> // if you were reading a text file you can
> // do any operations on each line as you go here
> }
>
>
> // 2. otherwise just read the whole file
> // in one go, e.g. for an image.
> $buffer = fgets($handle, 4096);
>
> // then you can write to the database or
> // do whatever with it here
>
> // close the file
> fclose($handle);
> }
>
>
> $uploaddir = '/home/folder1/htdocs/folder2/'.myfolder.'/';
> echo "<BR>YYYYYYYYYYY ".$uploaddir;
>
> $uploadfile2 = $_FILES['file']['tmp_name'];
> $uploadfile2 = preg_replace("/\/tmp\//", "", $uploadfile2);
>
> $uploadfile = $uploaddir . $uploadfile2 .".gif";
>
>
> //$$uploadfile2 =~ s/\/[a-zA-Z]\///g;
>
> //print "<pre>";
> if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
> print "File is valid, and was successfully uploaded. ";
> } else {
> print "Possible file upload attack! Here's some debugging info:\n";
> }
> //print "</pre>$uploadfile";
>
> chmod($uploadfile,0777);
>
> ----------------------------------------------------------
>
> But when I use this same code on a different server, it doesn't work as
> there seem to be no $_FILES['file']['tmp_name'].
> Is $_FILES['file']['tmp_name'] something configured by the server (I'm
> using Apache on a Linux system), or something default within PHP itself?
>
>
> Han.

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация