Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Request: Php Submit Script With Save In Host


14 replies to this topic

#1 farsiscript

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 357 posts
  • Interests:... No More !

Posted 09 May 2006 - 04:25 PM

Hi all
i want make one form whit php , when users submit there urls , then my site give one picture form url and save on my host !
how can do that ?
thanks

Edited by BuffaloHELP, 09 May 2006 - 06:45 PM.


#2 gaea

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 206 posts
  • Location:Vermont or Boston (USA)
  • myCENT:54.10

Posted 10 May 2006 - 12:31 AM

View Postfarsiscript, on May 9 2006, 04:25 PM, said:

Hi all
i want make one form whit php , when users submit there urls , then my site give one picture form url and save on my host !
how can do that ?
thanks

I'm sorry, but I'm not exactly sure what you mean.

I've gotten this far: You want a form that people can enter urls into. But what do you want to do with it afterwards? Do you want to save the url in a text file or data base? Are the urls links to images that you want to save? Please try to be more clear in your request, and I'll do my best to help you with it.

#3 farsiscript

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 357 posts
  • Interests:... No More !

Posted 11 May 2006 - 01:23 PM

No no ,
I want make one form , and then peoples come and post there url
when people send url by this form i want make one code to give url of website and gete picture form site
look's like this
at first i post my url in page
2 - the page give one picture form my site and save in host
3 - show the thats picture form my host

i want make this script to help gave pic form url

i want make this script for buy and sale templates
so , users login at site then post there url ( for exam : http://yoursite.com/index.htm) then my script must give one picture form index.htm
and save in my host at mysite/picure/httpyoursite.comindex.htm.jpg

thanks if you know some think about this project tell me please ,

Edited by farsiscript, 11 May 2006 - 01:25 PM.


#4 farsiscript

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 357 posts
  • Interests:... No More !

Posted 14 May 2006 - 01:28 PM

Hi mr gaea
do You have an Idea for this project ?
I have 2 choose :
1 - Tell Users To Take Picture form Web and Upload
2 - Make one PHP robot
how you think about this project ?
This project is web template sale Script , plz help me and guide me :)
thanks , :)

#5 jlhaslip

    Insert Custom Title Here

  • [MODERATOR]
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5,040 posts
  • Gender:Not Telling
  • Location:Linux, DOS and Windows…the good, the bad and the ugly
  • myCENT:81.07
  • Spam Patrol

Posted 14 May 2006 - 02:46 PM

farsiscript,
Best advise I can give you is to search for this script on the free sites like www.hotscripts.com.
If you want to learn some php in the process, there is a book written by Larry Ullman that includes the source code for a nearly identical application (log-in/log-out, registration, and error-checking functions) but you would still have to know some php to personalize it. The name of the book is "PHP and MYSQL for Dynamic Web Sites,
Second Edition". Chapter twelve has the application you want. Check your Local Library.

#6 gaea

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 206 posts
  • Location:Vermont or Boston (USA)
  • myCENT:54.10

Posted 15 May 2006 - 12:20 AM

View Postfarsiscript, on May 14 2006, 01:28 PM, said:

Hi mr gaea
do You have an Idea for this project ?
I have 2 choose :
1 - Tell Users To Take Picture form Web and Upload
2 - Make one PHP robot
how you think about this project ?
This project is web template sale Script , plz help me and guide me :)
thanks , :)

Sorry for the late reply, i've been really busy with my finals. Both of those solutions would work, but the easier version would deffinatly be number 2.

How much php do you know? I can give you the basic code you'll need for each...but you really should customize it for your individual purposes.

Anyways, for #1 you'd have a form that asks for the url of the photograph. You should really insert some error checking to make sure that it is infact an image (.jpg, .gif, or .png) instead of an exicuitable. The code would look something like this:
<?php
function http_get_file($url)  {

   $url_stuff = parse_url($url);
   $port = isset($url_stuff[‘port’]) ? $url_stuff[‘port’]:80;

   $fp = fsockopen($url_stuff[‘host’], $port);

   $query  = ‘GET ‘ . $url_stuff[‘path’] . ” HTTP/1.0\n“;
   $query .= ‘Host: ‘ . $url_stuff[‘host’];
   $query .= “\n\n“;

   fwrite($fp, $query);

   while ($line = fread($fp, 1024)) {
	  $buffer .= $line;
   }

   preg_match(‘/Content-Length: ([0-9]+)/’, $buffer, $parts);
   return substr($buffer, - $parts[1]);
}
?>
(take from http://damonparker.org/blog/2005/09/29/dow...ile-using-php/).
You'd then take the binary value that is returned, and write it into a file.

As far as #2 goes, there are lots and lots and lots of tutorials out there about how to make an image upload form. I find that htmlgoodies is usually a good resource for those first learning how to code. Check out their version of the tutorial at: http://www.htmlgoodi...cle.php/3472551 The one problem that i can find in that code is it doesn't check the file extention either.

If you have any more questions please feel free to post again.

#7 farsiscript

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 357 posts
  • Interests:... No More !

Posted 17 May 2006 - 12:37 PM

Hi Dear gaea and other friends
thanks about your help
i find this script and i thing i posting here to help u :
for storing image in sql without upload on hositng
i think storing image in sql is better uploading :

at first make form.htm :
" with this file you can post image

<form action="sql.php" enctype="multipart/form-data" method="post">
  <input type="file" name="image" /><br />
  <input type="submit" name="upload" value="Upload" />
</form>

at 2 make sql.php :

<?
// check wether the user pressed the upload button
if(isset($_POST['upload'])){
// below two lines connect to mysql and the mysql database
// change it according to your information
mysql_connect("localhost", "root", "");
mysql_select_db("img");

// below line opens the file chosen in the form for reading only
$file = fopen($_FILES['image']['tmp_name'], "r");
// then we read the file and add slashes to prevent errors when submitting to mysql
$image = addslashes(fread($file, filesize($_FILES['image']['tmp_name'])));

// inserts the null value as id, and our defined var $image to their corresponding cols.
// we use die(mysql_error()) as a error report if something screws up
mysql_query("insert into images values('null', '$image')") or die(mysql_error());

// if all goes well, echo the below line.
echo "image uploaded successfully";
}
?>

at 3 make view.php :
" this file show images form sql

<?
// changes our url id to the var $id
$id = $_GET['id'];

// connects to the database
//change info accordingly
mysql_connect("localhost", "root", "");
mysql_select_db("img");

// selects the binary data blob according to the id specified
// by our url
$result = mysql_query("select image from images where id = '$id'");
// tells php that contents of this page will be an image
header("(anti-spam-content-type:) image/jpeg");
// echoes our mysql query (echoes out the blob data)
echo mysql_result($result, 0);

?>
How To show images :
you can user this code :
<img src="view.php?id=1" alt="" />
for example if i browse view.php?id=2 then i can view 2 image in sql
with this script you can make secure (right click,save) image gallery or dont upload images
upload in host is not good , but storing data in database is very fast and secure
but my script has one problem i want make filter to members can not upload zip file or php file or an other file . i think with javascript i can do that but plz help me
thanks all

Edited by moderator, 22 May 2012 - 06:13 AM.


#8 gaea

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 206 posts
  • Location:Vermont or Boston (USA)
  • myCENT:54.10

Posted 17 May 2006 - 09:15 PM

Glad you found what you were looking for :) Feel free to post any other questions you run into...we're a pretty friendly bunch here.

#9 .hack//GU

    Premium Member

  • Kontributors
  • PipPipPipPipPipPipPipPip
  • 190 posts

Posted 19 May 2006 - 11:51 AM

Sometimes it's not a good idea to make the link of the picture intact with your site. I mean, think if somehow anyone post a annoying picture? maybe you should analyze the pictures first.

Anyway, if you want to convert the url into just txt, just use htmlentities(). It will discard the function of all HTML tags, so it won't do any HTML commands.

#10 farsiscript

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 357 posts
  • Interests:... No More !

Posted 21 May 2006 - 10:22 PM

how can i analyze picture format
i want make one soruce to analyze picture format
and if picture is in jpg format then accept image
else
send message to visitor (not good file format ) some think like this :)
end if
i think i do that whith javascript in form tag
thanks dear gaea , you and other firends here are nice programmer and good friend
if you find some kind of script plz post here
dear .hack//GU plz paste htmlentites () here with one sample
thanks , i tray to search htmlentites () in www.php.net
thanks all

Edited by farsiscript, 21 May 2006 - 10:24 PM.





Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users