<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.filesystem.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.is-uploaded-file.php',
    1 => 'is_uploaded_file',
    2 => 'Dice se un file f&ugrave; caricato via HTTP POST.',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Filesystem Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.is-readable.php',
    1 => 'is_readable',
  ),
  'next' => 
  array (
    0 => 'function.is-writable.php',
    1 => 'is_writable',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'it',
    'path' => 'reference/filesystem/functions/is-uploaded-file.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.is-uploaded-file" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">is_uploaded_file</h1>
    <p class="verinfo">(PHP 4 &gt;= 4.0.3, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">is_uploaded_file</span> &mdash; <span class="dc-title">Dice se un file fù caricato via HTTP POST.</span></p>

   </div>
   <div class="refsect1 unknown-628" id="refsect1-function.is-uploaded-file-unknown-628">
    <h3 class="title">Descrizione</h3>
     <div class="methodsynopsis dc-description">
      <span class="methodname"><strong>is_uploaded_file</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$filename</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

    <p class="para rdfs-comment">
     Restituisce <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> se il file chiamato per <code class="parameter">filename</code> è stato spedito in upload col metodo HTTP POST. Ciò è utile per rendere sicuro il fatto da un utente malizioso non abbia cercato di forzare uno script ad agire sul file sul quale non dovrebbe essere svolto alcun lavoro--ad esempio,
     <var class="filename">/etc/passwd</var>.
    </p>
    <p class="para">
     Questo controllo è particolarmente importante in caso esista una qualunque possibilità che una qualunque cosa che viaggia durante l&#039;upload del file, possa rivelarne il contenuto all&#039;utente, o anche ad altri utenti che operano sullo stesso sistema.
    </p>
    <p class="para">
     <span class="function"><strong>is_uploaded_file()</strong></span> è disponibile solo nella versione PHP 3, dopo la 3.0.16, e nella versione 4
     dopo la 4.0.2. Se hai delle perplessità nell&#039;usare una versione più recente, puoi utilizzare una delle seguenti funzioni per proteggere te stesso:
     <blockquote class="note"><p><strong class="note">Nota</strong>: 
      <p class="para">
       L&#039;esempio seguente <em>not</em> lavorerà con
       le versioni PHP 4 dopo la 4.0.2. Ciò dipende da funzionalità interne        a PHP che sono variate dopo tale versione.
      </p>
     </p></blockquote>
    </p>
     <div class="example" id="example-1">
      <p><strong>Example #1 <span class="function"><strong>is_uploaded_file()</strong></span> example</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/* Userland test for uploaded file. */<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">is_uploaded_file</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">) <br />{<br />    if (!</span><span style="color: #0000BB">$tmp_file </span><span style="color: #007700">= </span><span style="color: #0000BB">get_cfg_var</span><span style="color: #007700">(</span><span style="color: #DD0000">'upload_tmp_dir'</span><span style="color: #007700">)) {<br />        </span><span style="color: #0000BB">$tmp_file </span><span style="color: #007700">= </span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">tempnam</span><span style="color: #007700">(</span><span style="color: #DD0000">''</span><span style="color: #007700">, </span><span style="color: #DD0000">''</span><span style="color: #007700">));<br />    }<br />    </span><span style="color: #0000BB">$tmp_file </span><span style="color: #007700">.= </span><span style="color: #DD0000">'/' </span><span style="color: #007700">. </span><span style="color: #0000BB">basename</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">);<br />    </span><span style="color: #FF8000">/* User might have trailing slash in php.ini... */<br />    </span><span style="color: #007700">return (</span><span style="color: #0000BB">ereg_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">'/+'</span><span style="color: #007700">, </span><span style="color: #DD0000">'/'</span><span style="color: #007700">, </span><span style="color: #0000BB">$tmp_file</span><span style="color: #007700">) == </span><span style="color: #0000BB">$filename</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #FF8000">/* This is how to use it, since you also don't have<br /> * move_uploaded_file() in these older versions: */<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">is_uploaded_file</span><span style="color: #007700">(</span><span style="color: #0000BB">$HTTP_POST_FILES</span><span style="color: #007700">[</span><span style="color: #DD0000">'userfile'</span><span style="color: #007700">])) {<br />    </span><span style="color: #0000BB">copy</span><span style="color: #007700">(</span><span style="color: #0000BB">$HTTP_POST_FILES</span><span style="color: #007700">[</span><span style="color: #DD0000">'userfile'</span><span style="color: #007700">], </span><span style="color: #DD0000">"/place/to/put/uploaded/file"</span><span style="color: #007700">);<br />} else {<br />    echo </span><span style="color: #DD0000">"Possibile attacco su file in uploading: filename '</span><span style="color: #0000BB">$HTTP_POST_FILES</span><span style="color: #007700">[</span><span style="color: #0000BB">userfile</span><span style="color: #007700">]</span><span style="color: #DD0000">'."</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

    </div>
    <p class="para">
     Vedi anche <span class="function"><a href="function.move-uploaded-file.php" class="function">move_uploaded_file()</a></span>, e la sezione
     <a href="features.file-upload.php" class="link">Handling file uploads</a>
     per un semplice esempio di utilizzo.
    </p>
   </div>

  </div><?php manual_footer($setup); ?>