Jump to content

Writing and Submitting to a website


Deviatore

Recommended Posts

Hey, I am new to PHP and only now in the beginning.I am making a website related to photoshop, animation and other kinds of tutorials website.The thing is that i want an application in my website by which any person can submit a tutorial.

You can visit my website here once but i have just started to make it:

www.pixelspedia.com

(Please refresh it once if u cant see it)

I want something like this:

http://www.pixel2life.com/publish/write/

Please if someone can help me then I am ready to return him the same as much as I can.

 

Link to comment
Share on other sites

Here is a sample file to upload a tutorial in say "PDF" format. This example assumes there is  a Maximum file size. It then inserts the filename and title into a Database and uploads the file to a directory of your choice (make sure permissions are set for writing). The database will allow you to easily list your files. It is a good idea to follow the advice on the previous post not to make the file active by adding another field for approval (i.e. approved with values of 0 or 1 ) with the default being inactive.

 

There is probably more here than you need, but it is a way of uploading an existing file.

 

 
<?php

if ($submit) {

foreach($HTTP_POST_FILES as $value) { 
  foreach($value as $k => $v) { 
       echo $k.' => '.$v.'<br>'; 
    } 
} 
?> 
<?php 
// In PHP earlier then 4.1.0, $HTTP_POST_FILES should be used instead of $_FILES 

if($HTTP_POST_FILES['userfile']['name'] == '') { 
       echo 'You did not select a file to upload'; 
       } 
elseif($HTTP_POST_FILES['userfile']['size'] == 0) { 
   echo 'There appears to be a problem with the file your are uploading'; 
       } 
elseif($HTTP_POST_FILES['userfile']['size'] > $MAX_FILE_SIZE) { 
        echo 'The file you selected is too large'; 
       } 
elseif(!filesize($HTTP_POST_FILES['userfile']['tmp_name'])) {   
  echo 'The file you selected is not a valid file type'; 
     } 
else { 
   $uploaddir = '/usr/local/www/vhosts/Your_PATH_HERE/docs/'; // remember the trailing slash! 
   $uploadfile = $uploaddir. $HTTP_POST_FILES['userfile']['name']; 
   if(move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'], $uploadfile)) { 
       echo 'Upload file success!'; 
   } 
   else { 
       echo 'There was a problem uploading your file.<br>'; 
       print_r($HTTP_POST_FILES); 
   } 
} 
?> 
<?php
$db = mysql_connect("localhost", "YourUsername", "PASSWORD") or die("Could not connect");
$provridb = mysql_select_db("YOUR_DB_NAME",$db);

$name = $HTTP_POST_FILES['userfile']['name']; 

  $sql = "INSERT INTO tutorial ( title,filename,category, ) VALUES ('$title','$name','$category')";
  $result = mysql_query($sql);
  

  echo "Thank you! Your file was posted \n"; ?><br><br>
     <a href="add-doc.php"><span class="caption"><font color="#0033FF">Add Another Document</font></span></a>   |  <a href="logout2.php"><span class="caption"><font color="#0033FF">LOGOUT</font></span></a>    |   <a href="#">Go to DOC List page</a> (not active yet) <br>
<?php 
} else{

  // display form

  ?>
  
        <form enctype="multipart/form-data" name="docs" method="post" action="add-doc.php">
	<input type="hidden" name="category" value="env_doc">
         <span class="caption">Please provide the following information</span>:<br>
           
            <hr size="=0" color="#CCCCCC" width="200" align="left"> 


            <br>
            <br>
          File Title:
          <input name="title" type="Text" size="62">
            <br>
            <br>
            <input type="hidden" name="MAX_FILE_SIZE" value="900000">
            Upload this file:
            <input name="userfile" size="50" type="file"> 
            <BR>
            <br>
            <br>

                <input type="Submit" name="submit" value="Submit File">
     
                <input type="reset" name="Clear" value="Clear">

                                              <br>
                                  
                                  
          </p>
        </form>
      </p>                               
   <?php
} // end if
?>

Link to comment
Share on other sites

The whole thing is very simple.

Just the need is that i want to provide the user features like bolding the text, adding images, just like when u post something here, u have smilies, font change etc. and at last when it has to be published, it gets published in some format.

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.