help

how can i upload n download files in php thanks

[code]

Choose a file to upload:

[/code]

[php]// Where the file is going to be placed
$target_path = “uploads/”;

/* Add the original filename to our target path.
Result is “uploads/filename.extension” */
$target_path = $target_path . basename( $_FILES[‘uploadedfile’][‘name’]);
[/php]

PHP code for the uploader.php script in the example above is not quite complete. Here is what’s need to be added:
[php]<?php
$target_path = “uploads/”;

if(is_uploaded_file($_FILES[“uploadedfile”][“tmp_name”]) and $_FILES[“uploadedfile”][“error”]==0){
move_uploaded_file($_FILES[“uploadedfile”][“tmp_name”],$target_path.$_FILES[“uploadedfile”][“name”]);
}
else{
echo ‘File upload failed!’;
}
?>
[/php]

And directory /uploads must have proper permissions for php to write files there.

Sponsor our Newsletter | Privacy Policy | Terms of Service