FRIHOST • FORUMS • SEARCH • FAQ • TOS • BLOGS • COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Uploading files. Condition to continue...





pollux1er
I have written a sript to manage upload but ther is an error. Please help me.
This is the srcipt:

upload.php

Code:
<html>
<head></head>
<body>
<form method="POST" action="upfichier.php" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="300000" />
Envoyez ce fichier <input type="file" name="tof" />
<input type="submit" value=Envoyer />
</form>
</body>
</html>



upfichier.php

Code:
<?php

if (file_exists($rep)) {
   // echo "le dossier existe";
   }
   else { echo "le dossier n'existe pas";
   $com = mkdir($rep, 0770);
   }
   

$upfichier = basename($_FILES['tof']['name']);

$fich = explode(".", $upfichier);
$ext = $fich[1];

?>
<html>
<head></head>
<body>
<?php
if (file_exists($upfichier)) {

   echo "une photo existe déjà <br>";
   ?>
 <img src="<?php echo $upfichier; ?>" height="30%" width="20%"><br>

<?php echo "$upfichier <br>"; } ?>

<a href="">Remplacer</a>
<br>
<a href="">Annuler</a>

<?php

else

{

if (move_uploaded_file($_FILES['tof']['tmp_name'], $upfichier)) {

   echo "le fichier est valide et a ete telecharge avec succes";
   }
   else { echo "Attaque potentielle par telechargement de fichier";
      exit;
 } ?>
   
<img src="<?php echo $upfichier; ?>" height="30%" width="20%"><br>

<?php echo "$upfichier"; ?>

</body>
</html>


Please can you tell me the matter with that script...

Thanks to all

edit by rvec: please use code tags
sonam
Can you please post what error you get. Second. please, put your codes in code brackets, it is more easy for reading.

Sonam
pollux1er
Parse error on line 33!
rvec
pollux1er wrote:
Parse error on line 33!

Please just give the full error and with the same script.

I tried this script and I get this error:
Parse error: syntax error, unexpected T_ELSE in /var/www/test/upload/upfichier.php on line 35

normally you use the else command like this:
} else {
and make sure you have the same number of { and } Wink

also
Code:
if (file_exists($rep)) {
   // echo "le dossier existe";
} else {
   echo "le dossier n'existe pas";
   $com = mkdir($rep, 0770);
}


did you set $rep in your own script and just forgot to copy that? And why is $com set but nothing more done with it?

I recommend getting another script or rewriting this, it's not that hard and this doesn't look good to me.(partly because it looks french Razz )
pollux1er
I have anew code for the upload. It works well now. If you ask for it, i will post it. Thanks for your assistance.
Related topics
uploading files through web browser
Uploading Files
Uploading files error..
Issue with Nero Burning Rom when writing DVD Video Files
Uploading Files to the Database
RapidShare
uploading files
Uploading and resizing an image
Uploading Files..???
Trying to start out!!!
Uploading and unpacking Compressed Files
If You Are Replacing Notepad
Uploading files
Rapidgator Accelerator for download and uploading files
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.