Page 1 of 1

Help a newbi, ;)

Posted: Fri Feb 25, 2005 1:18 pm
by Maluendaster
hey all, I'm a newbi in this world of PHP and this is my first post, and hopefully not the last.

My question is that I wanna make a form that can upload an image, risize it to a given width and height, rename the file with 5 random numbers and give and ID (those 5 random numbers)... Why do I wanna do this? , i want to create a script that can upload images to a wap enabled server, then from the cell phone, put in a form the 5 numbers and download the image...

Thanks in avance and I hope you can understand me..

Saludos desde Chile!

PS : I forgot to say, i have tried for a long time now with no success, searching google, reading tutorials, but nothing that can help me.

Posted: Fri Feb 25, 2005 1:29 pm
by shiznatix
upload the image, get the extension, create a new image from that image with the set height&width, then save the image as a random numer.

for the image stuff look up imagecreatefromgif(); and the sort. I hate that area of php so im not much help there

for the random number you can do somthing like this (quick and not the best but it will work).

Code: Select all

$a = rand(0, 9);
$b = rand(0, 9);
$c = rand(0, 9);
$d = rand(0, 9);
$e = rand(0, 9);

$num = $a.$b.$c.$d.$e;

Posted: Fri Feb 25, 2005 2:58 pm
by Maluendaster
thanks man, i'll try to do something with that... thanks a lot...

Posted: Fri Feb 25, 2005 4:50 pm
by feyd
don't forget to check if this "random" number already exists.. you don't want to wipe out an old one.. or do you?

Posted: Fri Feb 25, 2005 5:12 pm
by Maluendaster
feyd wrote:don't forget to check if this "random" number already exists.. you don't want to wipe out an old one.. or do you?
right, thanks for that, if i ever finnish this script i'll post it here... ;)

Still studying what to do! ! :oops: I have absolutely no clue, but i think i'm in the right track...

..

Posted: Fri Feb 25, 2005 5:16 pm
by s.dot
If it's a unique image name that you're looking for, dealing with number, why not use:

Code: Select all

$num = time();
This will provide you with a unique number every time (unless an image is uploaded at the EXACT same time, which is unlikely).

Posted: Fri Feb 25, 2005 5:24 pm
by feyd
uh... it's actually quite possible.. given that the timestamp covers a full second. uniqid() may be a better choice.. but even then, you need to verify it doesn't exist already.

Posted: Fri Feb 25, 2005 11:39 pm
by Maluendaster
ok, right now I have 2 files, the problem is that the variable $clave doesnt show in the pass.php file ....

wap.php

Code: Select all

<?
header("Content-Type: text/vnd.wap.wml");
echo"<?xml version="1.0"?>"; ?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
			"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>			
<card id="Descarga" title="The Chilean Sanitarium">
<do type="accept" label="Enviar">
<go method="post" href="pass.php">
<postfield name="wall" value="$clave"/>
</go>
</do>
<p>
ID
<input title="name" name="wall"/><br/>
</p>
</card>
</wml>
pass.php

Code: Select all

<?
header("Content-Type: text/vnd.wap.wml");
echo"<?xml version="1.0"?>"; ?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
			"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>		
<a href="http://www.metallica.com/wap/<?echo  $HTTP_POST_VARS&#1111;'clave'] ?>.jpg">Descargar Wallpaper</a>
</wml>

Posted: Fri Feb 25, 2005 11:47 pm
by feyd
$clave is not set in wap.php... unless you have register_globals on (which isn't a good idea) or you include wap.php from another file, it won't exist.

Posted: Fri Feb 25, 2005 11:59 pm
by Maluendaster
feyd wrote:$clave is not set in wap.php... unless you have register_globals on (which isn't a good idea) or you include wap.php from another file, it won't exist.
how do i set $clave...

Posted: Sat Feb 26, 2005 12:11 am
by feyd
http://php.net/variables

you will also need to actually have the output for $clave processed by php. The code you posted has $clave outside of php's parsing.

Posted: Sat Feb 26, 2005 2:15 pm
by Maluendaster
i have no idea what to do next, can anyone please finnish or enlight me with something?