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
https://forums.phpfreaks.com/topic/38866-uploader/#findComment-186918
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
https://forums.phpfreaks.com/topic/38866-uploader/#findComment-186964
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
https://forums.phpfreaks.com/topic/38866-uploader/#findComment-186967
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.