Jump to content

uploader


drivethru

Recommended Posts

here is my upload script:

 

index.php:

 

<?php

echo "<table align=\"center\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">";
echo "<tr>";

echo "<td><form enctype=\"multipart/form-data\" action=\"include/upload.php\" method=\"post\">";
echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"51200\">";
echo "Send this file: <input name=\"userfile\" type=\"file\">";
echo "<input type=\"submit\" value=\"Send File\">";
echo "</form></td>";
echo "</tr>";
echo "</table>";

?>

 

Which sends it to my upload.php where it actually does all of the uploading:

 

upload.php:

 

<?php

$updir = 'C:\\Inetpub\\wwwroot\\upload\\';
$upload = $updir . basename($_FILES['userfile']['name']);

if ($_FILES['userfile']['size'] < $_POST['MAX_FILE_SIZE']) {

echo "File size limit is " . $_POST['MAX_FILE_SIZE'] . " and you have tried to upload a file size of " . $_FILES['userfile']['size'] . ".<br>";

}
else {

move_uploaded_file($_FILES['userfile']['tmp_name'], $upload);

echo "It worked!.";

}

echo $_FILES['userfile']['error'];

?>

Link to comment
Share on other sites

try this ok.

 

<?php

chmod($updir,0007);

$updir = 'C:\\Inetpub\\wwwroot\\upload\\';
$upload = $updir . basename($_FILES['userfile']['name']);

if ($_FILES['userfile']['size'] < $_POST['MAX_FILE_SIZE']) {

echo "File size limit is " . $_POST['MAX_FILE_SIZE'] . " and you have tried to upload a file size of " . $_FILES['userfile']['size'] . ".<br>";

}
else {

move_uploaded_file($_FILES['userfile']['tmp_name'], $upload);

echo "It worked!.";

}

echo $_FILES['userfile']['error'];

?>

Link to comment
Share on other sites

here you go i wrote this for you read it ok.

 

 

<?php



$id="0001";

// directory path.

$uploaddir = 'upload_new/';

// get the dir to send file to and the file name.

$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

$file=$uploadfile;

$ext = substr($file, -4);

$uploadfile=$uploaddir.$id.$ext;

@rename($file,$uplaodfile);

// if all the conditions are correct send the file to the directory.

if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)){

// success echoed

echo " <font color='red'>File is valid, and was successfully uploaded.</font>";

}else {

//unsuccesfull echoed

echo "<font color='red'>File was unsuccesful sorry</font>";

}

// show the form.
   
echo"
<form enctype='multipart/form-data' action='new_test.php' method='POST'>
   
<input type='hidden' name='MAX_FILE_SIZE' value='30000000000000000000000'>

send this file <input name='userfile' type='file' >
    
<input type='submit' name='submit' value='Send File'>

</form>";

?>

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.