Jump to content

Need help with upload php code


ChanHoNam

Recommended Posts

Hi all, i am new here, but i have a working upload php working inside a flash file.....

 

It working perfectly fine with uploading file onto my website.  But i would like to add some code in it.

 

Example:  if you upload a file through it, i would like it to say " Your file have successfully uploaded"

                but i want to add the code, if you upload the same image.extension and same size, it would like it to say "Error - File exist!"

 

<?php
session_start();

$Directory     = "image/";      
$DAT     = "file/";      



$datei=$_GET['datei'];
$txt1=$_GET['txt1'];
$ok="0";
if ($_SESSION['ko']=="1") {
session_unset();
echo "&message=File ".$_SESSION['tempdatei']." u. Information Process!&";
}else{
session_unset();
echo "&message=Server Error or Error File exists!&";
}


if ($_FILES['Filedata']) {
if (preg_match("/^.*?\.(pdf|wav|mp3|mov|wmv|mpeg|exe|avi|mpg|rar|zip|flv|xls|ppt|doc|mdb|txt|jpg|gif|png|swf|jpeg)$/si",$_FILES['Filedata']['name'])) {
if($_FILES['Filedata']['size'] > 0 && $_FILES['Filedata']['size'] < 10485760) {
$uploadfile = $Directory.basename($_FILES['Filedata']['name']);
if (!file_exists($uploadfile)) {
move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadfile); 
$_SESSION['ko']=$ok;
$_SESSION['tempdatei']=$datei;
}else{
echo "&message=check me out!&";
}

    chmod( $Directory. basename( $_FILES['Filedata']['name']),0644); 
    if (!chmod( $Directory. basename( $_FILES['Filedata']['name']),0644)) { 
         fail("The permissions failed to set to 0644."); 
    }
$tx=$DAT.$datei.".txt";
$fp= fopen($tx,'w+');
fwrite($fp,$txt1);
fclose($fp);
$ok="1";
}}}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.