PHP Classes

File: examples/example17_upload_form.php

Recommend this page to a friend!
  Classes of Naveed ur Rehman  >  PHP Class  >  examples/example17_upload_form.php  >  Download  
File: examples/example17_upload_form.php
Role: Example script
Content type: text/plain
Description: Upload a file to through HTML form
Class: PHP Class
Manage files and folders accounts
Author: By
Last change:
Date: 11 years ago
Size: 2,293 bytes


Class file image Download
                     HOW TO USE "PHP MEGAUPLOAD.COM CLASS"
 Example #17: Upload a file to through HTML form [caution: not for windows environment]
       Author: Naveed-ur-Rehman

require_once('../class/megaupload.class.php'); //php class file
require_once('credentials.php'); //Your signing in credentails of account

$megaupload = new megaupload_class(); //Initializing the class

$megaupload->username=$username; //Setting credentails (loaded from credentails.php)


$isconnect = $megaupload->connect(); //Return: 0=trouble, 1=validated and connected


//Uploading to local server (make sure that the current directory has writing permissions)

$filename = $_FILES['file']['name'];

$details = $_REQUEST["details"];

//Uploading to

$newfileid = $megaupload->upload($filename,$details);

"File has been uploaded. New file's link is <a href='$newfileid'>$newfileid</a>";}
"Error while uploading file.";}

//Removing file's copy on local server
"Error occured while connecting to May be username and/or password supplied is invalid.";

$megaupload->disconnect(); //Disconnect to release everything


<h1>Upload to</h1>
<form method="post" enctype="multipart/form-data">
 File: <input type="file" name="file" />
 Details: <input type="text" name="details" />
 <input type="submit" value="Upload">

For more information send a message to info at phpclasses dot org.