Jump to content
php.lv forumi

Upload Js/php


roberc

Recommended Posts

varbuut kaads zin kaadu skripta piemeera linku bilzhu aploudam uz web serveri ? tipa forma ar texta lauku un pogu BROWSE, tad upload. a PHP to sagremo un saglabaa...

cik esu mekleejis, visur kriit aaraa ASP piemeeri, kas man ir gauzhaam nepievilciigi

Link to comment
Share on other sites

<code><font color="#000000">

<form method='post' enctype="multipart/form-data" action='<font color="#0000CC"><? </font><font color="#006600">echo </font><font color="#0000CC">$PHP_SELF</font><font color="#006600">; </font><font color="#0000CC">?></font>'>
<input type='file' name='myfile'>
<input type='submit'>
</form>

<font color="#0000CC"><?
</font><font color="#006600">if(</font><font color="#0000CC">$_FILES</font><font color="#006600">[</font><font color="#0000CC">myfile</font><font color="#006600">][</font><font color="#0000CC">tmp_name</font><font color="#006600">]) { 
  </font><font color="#0000CC">[url=http://lv.php.net/copy]copy[/url]</font><font color="#006600">(</font><font color="#0000CC">$_FILES</font><font color="#006600">[</font><font color="#0000CC">myfile</font><font color="#006600">][</font><font color="#0000CC">tmp_name</font><font color="#006600">],</font><font color="#CC0000">"/direktorija/"</font><font color="#006600">.</font><font color="#0000CC">$_FILES</font><font color="#006600">[</font><font color="#0000CC">myfile</font><font color="#006600">][</font><font color="#0000CC">name</font><font color="#006600">]);
}
</font><font color="#0000CC">?>
</font>
</font>
</code>

 

Papildus:

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

http://lv.php.net/copy

Link to comment
Share on other sites

nu ja tev kaads linux, tad protams. ka vajag

un vispaar kods apmeeram shaads:

<code><font color="#000000">

if (is_uploaded_file($HTTP_POST_FILES['file_name']['tmp_name']))
{
   copy($HTTP_POST_FILES['file_name']['tmp_name'], "../tmp/$realname");
}
else

{
  echo "Possible file upload attack. Filename: " . $_FILES['file_name']['name'];
}
  if (move_uploaded_file($_FILES['file_name']['tmp_name'], "$realname"))
	{
	   echo "<b>File $realname was uploaded succesfully!</b>";
	   unlink("../tmp/$realname");
	}
 }
</font>
</code>

Link to comment
Share on other sites

a kuraa vietaa jaaskataas vai ir writes tiesiibas mapei ?

<code><font color="#000000">
<font color="#0000CC"><?
</font><font color="#006600">if(</font><font color="#0000CC">[url=http://lv.php.net/is_writable]is_writable[/url]</font><font color="#006600">(</font><font color="#CC0000">"/mape/"</font><font color="#006600">)){
  echo </font><font color="#CC0000">"Rakstām"</font><font color="#006600">;
  }else{
  echo </font><font color="#CC0000">"Nesanāks..."</font><font color="#006600">;
  }
</font><font color="#0000CC">?></font>
</font>
</code>

Link to comment
Share on other sites

×
×
  • Create New...