Jump to content

fileupload


qwe

Recommended Posts

i'am working on file upload 

 

so i have to add things on it 

 

like 

 

  • adding file name generation as in the pic > http://prntscr.com/gaoko3   
  • make the image appears before uploading to check if you want to or change other one
  • make the direct link appears after the image uploading done as in the pic >  http://prntscr.com/gaokvr

 

 

filename generation 

 

something like 98bzcx.png , .gif etc 

 

 

my code 

 

<!doctype html>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
      <body>
             <title>birdupload: upload</title>
       </body>
       </head>
<meta name="description" content="upload your image today">
<meta name="twitter:site" content="@">
       
<meta charset='UTF-8'/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
 
<nav><a href="gallery.php">gallery</a> | home</nav>
 
<h3> <img src="/images/logo.png"> </h3>
 
 
 
<!-- stylesheet -->
 
<!-- /stylesheet -->
 
<link rel="shortcut icon" href="favicon.ico">
<form action="upload.php" method="post" enctype="multipart/form-data">
browse:
<input type="file" name="image"><br/><br/>
<input type="submit" name="upload" value="continue">
</form>
 
        <ul>
            <li>sent file name: <?php echo $_FILES['image']['name'];  ?>
            <li>file size: <?php echo $_FILES['image']['size'];  ?>
            <li>file type: <?php echo $_FILES['image']['type'] ?>
        </ul>
             
<?php
 
    if(isset($_POST['upload'])){
    $image_name = md5($_FILES['image']['name']);
    $image_type = $_FILES['image']['type'];
    $image_size = $_FILES['image']['size'];
    $image_tmp_name= $_FILES['image']['tmp_name'];
    @$desc = $_POST['desc'];
    $allowed=array("image/jpeg", "image/gif", "image/png");
    if(!in_array($image_type,$allowed))
        echo "only jpg, gif, and png files are allowed.";
    else{
    move_uploaded_file($image_tmp_name,"uploads/$image_name");
    echo "<img src='uploads/$image_name' width='350' height='250'><br>";
    echo "your image:";
    }
 
}
 
 
 
 
           
           
?>

 

Link to comment
Share on other sites

OH! You're looking for programming skills for hire?  There is another forum for that.  Here we help people who are having difficulty with their code.  Code that they have written.

 

Programming is all about having a problem to solve.  Designing a possible solution.  Developing the code for that. And testing that it does what you need.  And repeat.

 

My suggestion - choose one problem and work on it.  If you have a very specific piece that you can't find a solution for (implying that you tried!) then show us what you have and ask a clear question on how to improve/fix it.  Don't just come here with your grandiose plans and hope that someone is going to jump up and write a hundred lines of code for you.

  • Like 1
Link to comment
Share on other sites

OH! You're looking for programming skills for hire?  There is another forum for that.  Here we help people who are having difficulty with their code.  Code that they have written.

 

Programming is all about having a problem to solve.  Designing a possible solution.  Developing the code for that. And testing that it does what you need.  And repeat.

 

My suggestion - choose one problem and work on it.  If you have a very specific piece that you can't find a solution for (implying that you tried!) then show us what you have and ask a clear question on how to improve/fix it.  Don't just come here with your grandiose plans and hope that someone is going to jump up and write a hundred lines of code for you.

i try to display the image with this code .

 

             
<?php
 
    if(isset($_POST['upload'])){
    $image_name = md5($_FILES['image']['name']);
    $image_type = $_FILES['image']['type'];
    $image_size = $_FILES['image']['size'];
    $image_tmp_name= $_FILES['image']['tmp_name'];
    @$desc = $_POST['desc'];
    $allowed=array("image/jpeg", "image/gif", "image/png");
    if(!in_array($image_type,$allowed))
        echo "only jpg, gif, and png files are allowed.";
    else{
    move_uploaded_file($image_tmp_name,"uploads/$image_name");
    echo "<img src='uploads/$image_name' width='350' height='250'><br>";
    echo "your image:";
 
$image=$_FILES["file"]["name"];

$img="upload/".$image;

echo '<img src= "upload/".$img>'

    }
 
}
 
 
 
 
           
     ?>

 

and it won't work  

ie: appears the image before uploading it 

 

i try to mix this code with my main code upload.php and won't work 

Edited by qwe
Link to comment
Share on other sites

You need to read your code with a closer eye.  Try echo-ing out what you built as a "image name" and you'll see what you did.

 

PS - when you get the image name properly built, check the server to be sure that the name you are trying to access does in fact exist.  PS - is the image located within the web-accessible tree?

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.