Bluehost.com Web Hosting $6.95

Re: [PHP] File upload

This is a discussion on Re: [PHP] File upload within the PHP General forums, part of the PHP Programming Forums category; a litle example of my upload file <form enctype="multipart/form-data" method="post" action=&...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-25-2003
desa15@necso.es
 
Posts: n/a
Default Re: [PHP] File upload


a litle example of my upload file

<form enctype="multipart/form-data" method="post" action="doupload.php" >
<p align="center">
<input name="userfile" type="file" size=30 style="font-family:v;
font-size: 10pt; color: #5E6A7B; border: 1px solid #5E6A7B; padding-left:
4; padding-right: 4; padding-top: 1; padding-bottom: 1"><br>
<br>
<button type="submit" style="font-family: v; font-size: 10pt; color:
#5E6A7B; border: 1px solid #5E6A7B; padding-left: 4; padding-right: 4;
padding-top: 1; padding-bottom: 1">Transferir</button>
</p>
</form>


doupload.php

<?php
include "configimage.php";

$image_name= $HTTP_POST_FILES['userfile']['name']; //El nombre original del
fichero en la máquina cliente.

$image_type= $HTTP_POST_FILES['userfile']['type'];//El tipo mime del
fichero (si el navegador lo proporciona). Un ejemplo podría ser
"image/gif".

$image_size= $HTTP_POST_FILES['userfile']['size'];//El tamaño en bytes del
fichero recibido.

$image_tmp= $HTTP_POST_FILES['userfile']['tmp_name']; //El nombre del
archivo temporal

$mime_type=array("image/jpeg",
"image/pjpeg",
"image/gif",
"image/x-png" );

$ext = strrchr($image_name,'.');

$endresult = "<font size=\"2\">El archivo ha sido transferido<br><a
target=_blank href=http://bmwfaq.com/uploads/$image_name>
http://www.bmwfaq.com/uploads/$image_name </a></font>";

if ($image_name == "") {
$endresult = "<font size=\"2\">No se han seleccionado
archivos</font>";

}elseif (($size_limit == "yes") && ($limit_size < $image_size)){
$endresult = "<font size=\"2\">El archivo es demasiado
grande</font>";

}elseif (($limit_ext == "yes") && (!in_array(strtolower
($ext),$extensions))) {
$endresult = "<font size=\"2\">Este tipo de archivo no está
permitido</font>";

} elseif (!in_array($image_type, $mime_type)) {
$endresult = "<font size=\"2\">Este tipo de archivo no es una
imágen</font>";

} elseif (file_exists("$absolute_path/$image_name")) {
$endresult = "<font size=\"2\">El archivo ya existe en el
servidor</font>";
} else {
if (is_uploaded_file($image_tmp)){
copy ($image_tmp,$absolute_path."/".$image_name);
}else{
"Possible file upload attack. Filename: " .
$HTTP_POST_FILES['userfile']['name'];
}

}
?>





"Peda"
<ena-mona@eunet.yu> Para: php-general@lists.php.net
cc:
25/07/2003 13:51 Asunto: Re: [php] Fileupload







>
> maybe you should try $HTTP_POST_FILES?
>

I have tryed that too, but nothing happened.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:18 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0