IMC!


Contents


Photos

 







Browsing around...
News  News Links  Links Blog  Blog Italiano  Español 
Simple php uploader

License
This software is free. You can use, distribute, modify it as you want. Pleas insert a link to my website www.giacobbe85.altervista.org .

Description
  1. index.htm: Simple HTML page for upload form;
  2. uploader.php: Simple PHP script which receives the file and copies it to upload folder.
  3. htaccess: Apache configuration file. It changes temporarily PHP variables to allow big size files upload. It works only if Apache allows it.

For further informations, read my small guide "Upload di file di grandi dimensioni" on my website http://www.giacobbe85.altervista.org .

Warning:
  1. Avoid to put this script in a pubblic page. Hackers might upload malicious software. Use it only in password protected pages.
  2. If already present, a file will be overwritten during upload.

You can download the whole code in this rar: Simple_php_uploader.rar

Code of index.htm
<!-- 
Name: Simple PHP Upload
Version: 1.0
Copyright: Isacco Coccato - www.giacobbe85.altervista.org

Please read readme_eng.txt for more informations
Per favore, leggi readme_ita.txt per maggiori informazioni
 -->

<HTML>
<HEAD>
  <TITLE>File upload</TITLE>
</HEAD>
<BODY>
  <TABLE border="0" height="100%" width="100%"><TR><TD align="center" valign="middle">
  <TABLE border="3" bordercolor="blue" cellpadding="10"><TR><TD align="center">
  <BR>

  <form enctype="multipart/form-data" action="uploader.php" method="POST">
    &nbsp;&nbsp;File to upload: &nbsp;&nbsp;<input name="uploadedfile" type="file" size="36" />&nbsp;&nbsp;
    <input type="submit" value="Carica" />&nbsp;&nbsp;<BR>
  </form>
  <DIV align="left">
    <B>WARNING:</B><BR>
    - Check file size.<BR>
    - If you close the window, the upload will stop.<BR>
  </DIV>
</TD></TR></TABLE>
</TD></TR></TABLE>
</BODY>
</HTML>

NOTA: The file name is uploader.php. I changed it to avoid its execution on this server

Code of uploader.phpp
<!-- 
Name: Simple PHP Upload
Version: 1.0
Copyright: Isacco Coccato - www.giacobbe85.altervista.org

Please read readme_eng.txt for more informations
Per favore, leggi readme_ita.txt per maggiori informazioni
 -->

<HTML>
<HEAD>
  <TITLE>File upload</TITLE>
</HEAD>
<BODY>
  <TABLE border="0" height="100%" width="100%"><TR><TD align="center" valign="middle">
  <TABLE border="3" bordercolor="blue" cellpadding="20"><TR><TD align="center">

    <?PHP
# ----- Settings ----

# Set here the upload directory. The path is relative
# Imposta quì il percorso di upload.  Il percorso è relativo
$target_path "uploads/";

# Messaggio in caso di upload eseguito correttamente (di default in english)
# Correct upload message (default english language)
$ok "Upload successful.<BR><BR>";

# Messaggio di errore (di default in english)
# Error message  (default english language)
$errore "There was an error.";

# Messaggio di nuovo upload (di default in english)
# Another upload message (default english language)
$ancora "Upload again";

# Program
$target_path $target_path basename$_FILES['uploadedfile']['name']); 
if(
move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) 
{
  
$dimensione=($_FILES['uploadedfile']['size'])/1000000;
  echo 
$ok basename$_FILES['uploadedfile']['name']) . "<BR>" $dimensione " Mb";

else
{
  echo 
$errore;
}
?>

<BR><BR>
<A href="index.htm"><?PHP echo $ancora?></A>
</TD></TR></TABLE>
</TD></TR></TABLE>
</BODY>
</HTML>

Code of htaccess
php_value upload_max_filesize 1000M
php_value post_max_size 1000M
php_value max_execution_time 200
php_value max_input_time 200






Comments

No comment present!

Write a comment

You can write here a comment to the article you've just read. Smiles, links and images are not allowed. The maximum comment length is 4000 characters. Please be polite, all the offensive messages will be deleted.

Your comment (lascia bianco!):
Uses (max 25 characters, required)
Web site (max 255 characters, optional)
e-Mail (max 255 characters, optional, will not be published) Your opinion (lascia bianco!):
Comment (max 4000 characters, required):





Valid HTML 4.01 Transitional
E-Mail - 58.46 ms

Valid HTML 4.01 Transitional