Hello,
I am trying to build a remote upload script for my image hosting site.
I am using $_GET for testing purposes.
this would be the url you would visit:
Code: http://jnerocorp.com/imagehost/beta2/remote.php?imgurl=http://www.phpfreaks.com/media/images/forums/logo.png
This is the error I am getting:
Code: Invalid url given
Im not really sure if this code would even work though I havnt been able to test it
here is the code:
<?php
$imgurl = $_GET['img_url'];
// define the filename extensions you're allowing
define('ALLOWED_FILENAMES', 'bmp|gif|ico|jpg|png|tiff');
// define a directory the webserver can write to
define('IMAGE_DIR', '/images');
// check against a regexp for an actual http url and for a valid filename, also extract that filename using a submatch (see PHP's regexp docs to understand this)
if(!preg_match('#^http://.*([^/]+.('.ALLOWED_FILENAMES.'))$#', $imgurl, $m)) {
die('Invalid url given');
}
// try getting the image
if(!$img = file_get_contents($_GET['img_url'])) {
die('Getting that file failed');
}
$handle = fopen("$imgurl", "rb");
$filesize = fread($handle, filesize($myFile));
fclose($handle);
if($filesize <= 1048576) {
// try writing the file with the original filename -- note that this will overwrite any existing filename in the same directory -- that's up to you to check for
if(!file_put_contents(IMAGE_DIR.'/'.$m[1], $img)) {
die('Writing the file failed');
}
$uid = uniqid();
$image = $m[1].$img;
$master = $uid.$image;
rename("/images/".$m[1].$img."", "/images/".$master."");
$fullurl = "http://JneroCorp.com/imagehost/beta2/images/".$master."";
echo "<img src='$fullurl'>";
}
?>
why this query can delete duplicates ?
why this query can delete duplicates ? Anybody can give me the detailed explanation ?
Character Sets/Collations Stuff
Can someone please give me a check list of things I must do to setup all the charset stuff for my php/mysql social site*only for a USA town doesn't require non english characters*
pageination not working right... coping images over 4 pages
Code: <?php //This code will obtain the required page number from the $_GET array. Note that if it is not present it will default to 1.if (isset($_GET['pageno'])) { $pageno =
media recovery
Hi, i startup the database i got the errorSQL> startupORACLE instance started.Total System Global Area 146800640 bytesFixed Size 1286220 bytesVariable Size 79695796
Undefined variables
hi----------------------------------------------------------------------------------------------------error log "[Sat Jan 09 17:40:00 2010] [error] [client 127.0.0.1] PHP Notice: Undefined
Warning: mysql_num_rows() expects parameter 1
When i add quote at the end of this linkexample:http://localhost/articlemania/category.php?cid=3" it's give me an errorhere is :" Warning: mysql_num_rows() expects parameter 1 to be
Curl & sessions PLS HELP
Hello,I have a problem with curl and sessions and i will try to explain the best i could.01. I want to download a file from (http://subdomain.example.com/name-13075.html) with curl.02. The problem is:
ORA-00932: inconsistent datatypes: expected - got CLOB
SO : windows xp
php mysql script to find record
Hi, Currently I have a simple table with 4 columns. A, B, C, D If I want to find all the records with the similar value in column B. How can i write a simple query to match this one ? Please advise.
Amatuer requiring assistance
Beginner and amateur in need of assistanceMy Site - (Spare Parts for Domestic Appliances)I've gone as far as I can go on my own and need guidanceWhat I require is custom searches - I need to return