Jump to content
php.lv forumi

upload


ziedinjsh

Recommended Posts

es jau lietoju uzpload scriptu, bet viņam ir tikai loader.gif bilde :D

php

<?php
session_start();
if(isset($_SESSION['email'])){

include "html.php";
include "header.php";
include "menu.php";

$row = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE email = '{$_SESSION['email']}'"));

if (isset($_POST['song'])){

$user_id = $row['user_id'];
$folder = "mp3/";
$result = 0;
$file = $folder . basename( $_FILES['song']['name']);
$song = basename($_FILES['song']['name']);




  sleep(1);

  echo "<script language='javascript' type='text/javascript'>window.top.window.stopUpload(".$result.");</script>";


}


echo "<form method='post' action='".$_SERVER['PHP_SELF']."' enctype='multipart/form-data' target='upload_target' onsubmit='startUpload();' >";
echo "<div id='loader-proces'><img src='misc/loader.gif' /><br>luudzu uzgaidiet kameer dziesma augshupielaadeejas</div>";                     
echo "<div id='form-proces'>";
echo "<input name='song' type='file' size='30' class='login-box'/><input type='submit' name='song' class='login-button' value='Upload' />";
echo "</div>";
echo "<iframe id='upload_target' name='upload_target' src='#' style='width:0;height:0;border:0px solid #fff;'></iframe>";                                        
echo "</form>";



include "footer.php";
}else{
header("Location:index.php");
}
?>

 

JS


function startUpload(){
     document.getElementById('loader-proces').style.visibility = 'visible';
     document.getElementById('form-proces').style.visibility = 'hidden';
     return true;
}

function stopUpload(success){
     var result = '';
     if (success == 1){
        result = '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>';
     }
     else {
        result = '<span class="emsg">There was an error during file upload!<\/span><br/><br/>';
     }
     document.getElementById('loader-proces').style.visibility = 'hidden';
     document.getElementById('form-proces').innerHTML = result + '<meta http-equiv="refresh" content="2">';
     document.getElementById('form-proces').style.visibility = 'visible';      
     return true;   
}

 

varbūt var kāds pielāgot kādu JS rindu lai ir arī progresbar kas skaita prcentuāli vai nk kāds krāsu stabiņš kas atbilst progresam ??

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...