Jump to content

usapphire

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Posts posted by usapphire

  1. I don't know where the "edit" button is, but I also have another problem.. when someone "downloads" a file, the link only displays the first word, for example, if the file is called "My File.jpg", it will only display "My", and when downloaded, will be a file called "My".. so people won't be able to open it without changing the name..

     

    Can this be fixed?

  2. Hello! Thank you for the very useful reply! There seems to be a problem though.. Where do I locate php.ini? I have a reseller account of a shared hosting, so would that mean I need to contact the server host to change the php.ini? Or should I make a new one in the /etc/ folder?

     

    The iptables rules for this are as follows:

    # allow all fragments

    -A INPUT -f -j ACCEPT

    # allow icmp traffic

    -A INPUT -p icmp -j ACCEPT

    Where do these go? I'm still new to php, so I don't exactly understand where to put these.. :(

    Thank you.

  3. Theres a few things you need mate:

     

    1. max post setting

    2. max file upload setting

    3. max script execution time

    4. Apache Limitrequestbody is not too low

     

    I have also personally experienced an issue with my IPTABLES script which was preventing large uploads... I had to add:

     

    # allow all fragments
    -A INPUT -f -j ACCEPT
    # allow icmp traffic
    -A INPUT -p icmp -j ACCEPT
    

     

    This is explained in the php manual file uploads page.

     

     

    Hello, and thank you for the reply! I don't exactly understand where to put this code, and where do I find the codes / tutorials on how to do the 4 points you listed above? If you want, can I post my full upload script here and have it edited to the way it should work? If this is asking too much, can you point me in the right direction (for tutorials, or something similar)? :D

     

    If you can do it for me, I'll repay you by giving you a free webhosting space.. as much as up to 50GB of server space, and whatever bandwidth..

  4. Hi again - just like to say thank you for previous help.

     

    Just a quick one today, I'm quite sure it's just me doing something completely wrong. After uploading my previous upload/download script and getting it to work (refer to my other topics;

    Upload & Download Script and Error in uploading file), it ended up not working completely right.

     

    I had someone try to upload a 10 mb file, and it came with an error.. I realized this must have something to do with the max upload allowed, and so, in my .htaccess file, I set it to;

    php_value upload_max_filesize 1000M

    Just to see if it'll work.

     

    Still no luck. After trying to upload a 10 mb file, I think it "times out" within 3-4 minutes. It refreshes the page, where it's suppose to display the "FILE HAS BEEN UPLOADED SUCCESSFULLY", but displays nothing - nor is the file uploaded to the directory, listed on the download list, or even added to the MySQL.

     

    Does anyone know what might be the problem?

     

    Thank you (I can post the site for those who want to try it out, but it contains 16+ content (it's an upload site for aarinfantasy.com).

  5. like this:

     

    <input name="upload" type="Submit" id="upload" value="Upload" onclick="showProgress(); this.disabled=true; this.submit()">
    

     

    i think, i am not to sure, javascript isnt my strong.

    It disables it, but still doesn't submit.. :( This is what's been happening..

  6. just add like: document.form_name.submit somewhere, i am pretty sure that would work. put it after the disabled submit button.

    Sorry, should this go <input name="upload" type="Submit" id="upload" value="Upload" onclick="showProgress();" onclick="this.disabled=true;" HERE>? I don't understand.

  7. Why does it matter if they click it more than once?

    It's an upload site.. if they click it more than once, it'll restart the upload? I allowed files up to 100mb to be uploaded, so I don't think people who want to upload a file 100mb want to keep clicking it if they think it'll make it go fast..  :-\

  8. $ext = substr(strrchr($fileName, "."), 1);

    Shouldn't this be more like

    $ext = substr($fileName, strrpos($fileName, "."));

    Changed, and it didn't seem to make a difference.. However, I found something that made the error.

     

    <script>
    function submitonce(theform){
    if (document.all||document.getElementById){
    for (i=0;i<theform.length;i++){
    var tempobj=theform.elements[i]
    if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
    tempobj.disabled=true
    }
    }
    }
    </script>

    This code is located in the header.php file between <HEAD></HEAD>. It's to prevent people from clicking "Upload" (submit button) more than once.. If I take it off, it works - but now I'm left with the Upload button still able to be clicked. Does anyone have another code that may allow it to work? Or know how I can change this one so it can work?

     

    Thank you ^_^

     

    EDIT: Just a note, it has actually worked in the past with the code!! Thanks again.

     

     

  9. 777 is default. I can't create the folder, so how can I CHMOD it?

     

    Actually, this is weirder - the folder already exists, so it shouldn't be trying to mkdir it - it's like it can't see $moveTo in the is_dir and mkdir commands...but I can print it out right before.

    I'm sorry, I'm not very PHP-logic.. Maybe someone else can help?

    Sorry.. :(

  10. Hey everyone  :D

    Thanks previously for your help!

     

    I have a quick problem, which I'm sure is just something very silly.. I made an upload script thanks to PHP Freaks and the person who replied to my previous forum, but after finally finishing it.. there seemed to be an error. Okay, so this is what I did:

     

    1. Script worked fine. Integrated into the site layout with no problem.

    2. Made "categories" within the site.. So this means that there is more than 1 upload/download page.*

    3. Made the MySQL databases to hold data for the other categories.

    4. Uploaded the new pages, and CHMOD the upload folder to 777.

    5. Tried it out - doesn't work anymore.

     

    * The different categories are on different pages. For example; category1.php, category2.php, etc.

     

    Here is the code I'm using.

     

    Upload form / display download files page.

    <?php include("header.php"); ?>
    <div align="center"><img src="images/index_category1.jpg" border="0"></div><br>
    
    <?php
    $uploadDir = 'category1/upload/';
    
    if(isset($_POST['upload']))
    {
    $fileName = $_FILES['userfile']['name'];
    $tmpName = $_FILES['userfile']['tmp_name'];
    $fileSize = $_FILES['userfile']['size'];
    $fileType = $_FILES['userfile']['type'];
    
    // get the file extension first
    $ext = substr(strrchr($fileName, "."), 1);
    
    // make the random file name
    $randName = md5(rand() * time());
    
    // and now we have the unique file name for the upload file
    $filePath = $uploadDir . $randName . '.' . $ext;
    
    $result = move_uploaded_file($tmpName, $filePath);
    if (!$result) {
    echo "There was an error uploading the file. Click the back button and try again.";
    exit;
    }
    
    include 'category1/config.php';
    include 'category1/opendb.php';
    
    if(!get_magic_quotes_gpc())
    {
    $fileName = addslashes($fileName);
    $filePath = addslashes($filePath);
    }
    
    $query = "INSERT INTO upload2 (name, size, type, path ) ".
    "VALUES ('$fileName', '$fileSize', '$fileType', '$filePath')";
    
    mysql_query($query) or die('Error, query failed : ' . mysql_error());
    
    include 'category1/closedb.php';
    
    echo "<div align=center><font color=red><b>YOUR FILE HAS BEEN UPLOADED!</b><br></div></font>The Direct link is found on the right of your file name. Can't see your file? New uploaded files are placed on the bottom of the list, so scroll down. To copy the link, Right-Click on the <b>DOWNLOAD FILE</b> text, and select <b>Copy Link Location</b> or <b>Copy Shortcut</b>. Thank you for using our services!</font><br>";
    
    }
    ?>
    
    <script>
    function showProgress(){document.getElementById('progressRow').style.display = 'inline';
    }
    </script>
    
    <div align="center">
    <span id="progressRow" style="display:none;"><table border=0 cellpadding=10 cellspacing=0 class=forText width=90%><tr><td valign=middle bgcolor=#ececec><div align=center><b><font color="black"><div align="center">Your file is being uploaded. Please wait <img src="images/dot.gif"></div></b></font></tr></td></table></span></div>
    
    <form method="post" enctype="multipart/form-data" onSubmit="submitonce(this)">
      <table border="0" cellpadding="0" cellspacing="5" class="forText">
        <tr> 
          <td><img src="images/index_52.jpg"></td><td><input name="userfile" type="file" id="userfile" size="35" class="forText">
             </td>
          <td><input name="upload" type="Submit" id="upload" value="Upload" onclick="showProgress();" onclick="this.disabled=true;"></td>
        </tr>
      </table>
    <div align="center">
    <table border=0 cellpadding=10 cellspacing=0 class=forText width=90%><tr><td valign=middle bgcolor=#ececec><div align=center>-DISCLAIMER-</tr></td></table>
    </div>
    </form><br><br>
    
    <?php include("category1_download.php"); ?>
    <?php include("footer.php"); ?>

     

     

    The Download page (script for include)

    <?php
    error_reporting(E_ALL);
    if(isset($_GET['id']))
    {
        include 'category1/config.php';
        include 'category1/opendb.php';
    
        $id      = $_GET['id'];
        $query   = "SELECT name, type, size, path FROM upload2 WHERE id = '$id'";
        $result  = mysql_query($query) or die('Error, query failed');
        list($name, $type, $size, $filePath) = mysql_fetch_array($result);
    
        header("Content-Disposition: attachment; filename=$name");
        header("Content-length: $size");
        header("Content-type: $type");
        
        readfile($filePath);
    
        include 'category1/closedb.php';    
        exit;
    }
    
    ?>
    
    <?php
    include 'category1/config.php';
    include 'category1/opendb.php';
    
    $query  = "SELECT id, name FROM upload2";
    $result = mysql_query($query) or die('Error, query failed');
    if(mysql_num_rows($result) == 0)
    {
        echo "<div align=center><table border=0 cellpadding=5 cellspacing=0 class=forText width=90%><tr><td valign=middle bgcolor=#ececec><div align=center>There are no files uploaded in this directory. <b>Be the first!</b></tr></td></table></div>";
    } 
    else
    {
        while(list($id, $name) = mysql_fetch_array($result))
        {
    ?>
        <table border=0 cellpadding=0 cellspacing=5 class=forText width=100%><tr><td valign=middle bgcolor=#ececec width=75><div align=center>
    <img src=images/category1.jpg></div></td><td valign=middle bgcolor=#ececec><div align=center><?=$name;?></div></td><td valign=middle bgcolor=#ececec width=100><div align=center><a href="category1_download.php?id=<?=$id;?>">DOWNLOAD FILE</a></div></tr></td></table>
    <?php        
        }
    }
    include 'category1/closedb.php';
    ?>

     

    The error that comes up is "There was an error uploading the file. Click the back button and try again."  ???

  11. Found one.. Thanks again for your help! For everyone else who wants to know:

     

    <?
    
    $file_dir="FILE_DIRECTORY";
    
    $dir=opendir($file_dir);
    while ($file=readdir($dir))
    {
    	if ($file != "." && $file != "..")
    	{
    		echo "<a href=".$file_dir."/".$file." target=_blank>".$file."</a>";
    		echo "<br>";
    	}
    }
    
    ?>

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