You are viewing our Forum Archives. To view or take place in current topics click here.
Need Help With PHP
Posted:

Need Help With PHPPosted:

Fearful
  • Ladder Climber
Status: Offline
Joined: Dec 12, 201211Year Member
Posts: 316
Reputation Power: 14
Status: Offline
Joined: Dec 12, 201211Year Member
Posts: 316
Reputation Power: 14
ok im making an image upload script with php sortta like [ Register or Signin to view external links. ] and need help with showing the image once it has been uploaded i have Skype etc please help, thanks
#2. Posted:
TTGXMODsX
  • TTG Natural
Status: Offline
Joined: Feb 06, 201014Year Member
Posts: 996
Reputation Power: 64
Status: Offline
Joined: Feb 06, 201014Year Member
Posts: 996
Reputation Power: 64
Can you tell me if the image is being stored in a database?
#3. Posted:
Fearful
  • Ladder Climber
Status: Offline
Joined: Dec 12, 201211Year Member
Posts: 316
Reputation Power: 14
Status: Offline
Joined: Dec 12, 201211Year Member
Posts: 316
Reputation Power: 14
TTGXMODsX wrote Can you tell me if the image is being stored in a database?
no its being stored to /images/ then the random name given
#4. Posted:
TTGXMODsX
  • TTG Natural
Status: Offline
Joined: Feb 06, 201014Year Member
Posts: 996
Reputation Power: 64
Status: Offline
Joined: Feb 06, 201014Year Member
Posts: 996
Reputation Power: 64
Fearful wrote
TTGXMODsX wrote Can you tell me if the image is being stored in a database?
no its being stored to /images/ then the random name given


First of all you should be using a database to store the filename and path as if you have a user account page different users will have different images for their profiles. Therefore you need an upload image that will save the image path and name on the database where at the same time inserting the uploaded image into your directory. Now to display the image you will need to retrieve the users image using a sql statement and using an imageControl.
#5. Posted:
Fearful
  • Ladder Climber
Status: Offline
Joined: Dec 12, 201211Year Member
Posts: 316
Reputation Power: 14
Status: Offline
Joined: Dec 12, 201211Year Member
Posts: 316
Reputation Power: 14
TTGXMODsX wrote
Fearful wrote
TTGXMODsX wrote Can you tell me if the image is being stored in a database?
no its being stored to /images/ then the random name given


First of all you should be using a database to store the filename and path as if you have a user account page different users will have different images for their profiles. Therefore you need an upload image that will save the image path and name on the database where at the same time inserting the uploaded image into your directory. Now to display the image you will need to retrieve the users image using a sql statement and using an imageControl.


i dont want to use sql or database at that matter just show the image below once they have uploaded it ive seen it many times before
#6. Posted:
Slagveld3
  • Prospect
Status: Offline
Joined: Dec 27, 201112Year Member
Posts: 696
Reputation Power: 35
Status: Offline
Joined: Dec 27, 201112Year Member
Posts: 696
Reputation Power: 35
Okay, Just wrote this but umh,

The HTML:
<form action="upload.php"  enctype="multipart/form-data"
method="POST">
  <p>Select a file:
    <input type="file" name="user_file[1]" size="50">
      <br />
<input type="file" name="user_file[2]" size="50">
      <br />
<input type="file" name="user_file[3]" size="50">
<br />

      <input type="submit" name="submit" value="Upload Now" />
</p>
</form>


and the PHP:

<?
session_start();
$n=$_FILES['user_file']['name'];
$type=$_FILES['user_file']['type'];
$size=$_FILES['user_file']['size'];
$time=time();
$n=$time;
$path="upload/". $n;




$uploaded = $_SESSION['firsttimeupload'];

if ($uploaded == "ok")
{
       if ($size <100000 && ereg("image", $type  ))
          {
         move_uploaded_file($_FILES['user_file']['tmp_name'],
         $path);
         
         $root= "http://www.url.com/form/upload/";
         $path2=$root . $n;
         echo "<center>";
         echo "<h3>Your Image Link Is: </h3><a href=$path2>$path2</a><br><br>";
         echo "<br>";
         echo "<img src=$path2 border='5'></img>";
         echo "<center>";
         
         
         $fp=fopen("links.text", "at");
         fwrite($fp, $path2."\n");
         fclose($fp);
         session_destroy();
          }       
}    
else
{
echo "you cant upload the same image many times per session go back and choose  it or another one";

       
////////////
     if ($size>100000)
       {
echo "ERROR <br> the image size is too big";
       }

     if (!ereg("image", $type) )
      {
echo "ERROR <br> the file is not image<br>";
       }
      
   
echo"<br><br><h2><a href='library.php'>View Images Library</a></h2>";
echo "<body bgcolor='#FF6699'>"
?>


Something like this. If any errors occur please tell me. Made this in like 5 min.
#7. Posted:
Fearful
  • Ladder Climber
Status: Offline
Joined: Dec 12, 201211Year Member
Posts: 316
Reputation Power: 14
Status: Offline
Joined: Dec 12, 201211Year Member
Posts: 316
Reputation Power: 14
Slagveld3 wrote Okay, Just wrote this but umh,

The HTML:
<form action="upload.php"  enctype="multipart/form-data"
method="POST">
  <p>Select a file:
    <input type="file" name="user_file[1]" size="50">
      <br />
<input type="file" name="user_file[2]" size="50">
      <br />
<input type="file" name="user_file[3]" size="50">
<br />

      <input type="submit" name="submit" value="Upload Now" />
</p>
</form>


and the PHP:

<?
session_start();
$n=$_FILES['user_file']['name'];
$type=$_FILES['user_file']['type'];
$size=$_FILES['user_file']['size'];
$time=time();
$n=$time;
$path="upload/". $n;




$uploaded = $_SESSION['firsttimeupload'];

if ($uploaded == "ok")
{
       if ($size <100000 && ereg("image", $type  ))
          {
         move_uploaded_file($_FILES['user_file']['tmp_name'],
         $path);
         
         $root= "http://www.url.com/form/upload/";
         $path2=$root . $n;
         echo "<center>";
         echo "<h3>Your Image Link Is: </h3><a href=$path2>$path2</a><br><br>";
         echo "<br>";
         echo "<img src=$path2 border='5'></img>";
         echo "<center>";
         
         
         $fp=fopen("links.text", "at");
         fwrite($fp, $path2."\n");
         fclose($fp);
         session_destroy();
          }       
}    
else
{
echo "you cant upload the same image many times per session go back and choose  it or another one";

       
////////////
     if ($size>100000)
       {
echo "ERROR <br> the image size is too big";
       }

     if (!ereg("image", $type) )
      {
echo "ERROR <br> the file is not image<br>";
       }
      
   
echo"<br><br><h2><a href='library.php'>View Images Library</a></h2>";
echo "<body bgcolor='#FF6699'>"
?>


Something like this. If any errors occur please tell me. Made this in like 5 min.
i sent u a pm
#8. Posted:
Z61
  • TTG Fanatic
Status: Offline
Joined: Apr 16, 201014Year Member
Posts: 4,309
Reputation Power: 179
Status: Offline
Joined: Apr 16, 201014Year Member
Posts: 4,309
Reputation Power: 179
You should probably learn the php yourself, instead of looking for a handout.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.