CircularStopSign
Members-
Posts
44 -
Joined
-
Last visited
Profile Information
-
Gender
Not Telling
CircularStopSign's Achievements
Member (2/5)
0
Reputation
-
i need to create 1000 folders, 1-1000 but i dont feel like creating it all by hand, is there any loop code that i could use to do this for my web server?
-
renaming file during upload....
CircularStopSign replied to CircularStopSign's topic in PHP Coding Help
yeah, this works... i was just posting it so everyone could see it.... maybe point out some flaws if they see any.. your the man humpty -
renaming file during upload....
CircularStopSign replied to CircularStopSign's topic in PHP Coding Help
for the extensions i just built a simple if statement... i dunno if its safe or w/e but its whati go fo rnow [code] if($FnameExt==$ext_array[0] || $FnameExt==$ext_array[1] || $FnameExt==$ext_array[2] || $FnameExt==$ext_array[3] || $FnameExt==$ext_array[4]){ if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path.'/'.$randomName.".".$FnameExt)) { echo htmlentities('<a href="http://www.hostmapics.com/"><img src="http://hostmapics.com/'); echo $target_path.'/'.$randomName.".".$FnameExt; echo htmlentities('"></a>'); } else{ echo "There was an error uploading the file, please try again!"; } } else{ echo "Not a valid file extension"; } [/code] when i get to the directories i am either going to use a database or do a random 1-1000 to pick which folder the image is going in -
multiple condidtions in an if statement
CircularStopSign replied to CircularStopSign's topic in PHP Coding Help
alright thanks... i was thinking something like that, but i wasnt sure. i think its the same in JS right? -
how would i say: if(stuff==array[0] or array[1] or array[2]){ echo "Stuff is equal too 0,1, and 2"; } haha sounds kind of childish but i cant find it anywhere i can only find &&
-
renaming file during upload....
CircularStopSign replied to CircularStopSign's topic in PHP Coding Help
alright, thanks a lot that really helped, i'll give you my code just so you can see it if youd like. [code] <?php $Fname=$_FILES['uploadedfile']['name']; //Function to strip the extension of a filename string function strip_ext($name) { $ext = strrchr($name, '.'); if($ext !== false) { $name = substr($name, 0, -strlen($ext)); } return $name; } // This will get the extension of the filename $FnameExt= end(explode('.',$Fname)); function createRandomName() { $chars = "abcdefghijkmnopqrstuvwxyz023456789"; srand((double)microtime()*10000000); $i = 0; $pass = '' ; while ($i <= 7) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $pass = $pass . $tmp; $i++; } return $pass; } // Usage $randomName = createRandomName(); //retrieve file name // Where the file is going to be placed $target_path = "images"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = "images"; $_FILES['uploadedfile']['tmp_name']; if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path.'/'.$randomName.".".$FnameExt)) { //show the user their link echo htmlentities('<a href="http://www.hostmapics.com/"><img src="http://hostmapics.com/'); echo $target_path.'/'.$randomName.".".$FnameExt; echo htmlentities('"></a>'); } else{ echo "There was an error uploading the file, please try again!"; } ?> [/code] heres what i need to work on now: -an extension verification script -use a database or random selection for dir 1-1000 for the images/****/name.ext what else do i need? and should i use classes or should i just do everything on this page like i am now? -
renaming file during upload....
CircularStopSign replied to CircularStopSign's topic in PHP Coding Help
alright thanks, i'll try it out tomorrow i really appreciate it :) -
renaming file during upload....
CircularStopSign replied to CircularStopSign's topic in PHP Coding Help
didnt work... in order to change the file name, dont i have to store the extension some how first? -
renaming file during upload....
CircularStopSign replied to CircularStopSign's topic in PHP Coding Help
i changed it to "basename($_FILES['randomName']..." then changed the rest of the "uploadedfile" to randomName also, but im guessing that doesnt work because it doesnt recognize the file because from the form i named it "uploadedfile" so i need somehow to change it from uploadedfile to a randomName...? maybe thats not what you were saying? -
renaming file during upload....
CircularStopSign replied to CircularStopSign's topic in PHP Coding Help
wow sorry, that code wasnt supposed to be in there, it doesnt work with the rename function the way i had it... so pretend that isnt in there please, then help me i will take it out thanks, pat -
i've looked all over, but i cant figure out how i would change the file name to a randomly generated name... heres my code so far [code] <?php function createRandomName() { $chars = "abcdefghijkmnopqrstuvwxyz023456789"; srand((double)microtime()*10000000); $i = 0; $pass = '' ; while ($i <= 7) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $pass = $pass . $tmp; $i++; } return $name; } $randomName = createRandomName(); // Where the file is going to be placed $target_path = "images/"; /* Adding the original filename to my target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename($_FILES['uploadedfile']['name']); $_FILES['uploadedfile']['tmp_name']; if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo htmlentities('<a href="http://www.hostmapics.com/"><img src="http://hostmapics.com/'); echo $target_path; echo htmlentities('"></a>'); } else{ echo "There was an error uploading the file, please try again!"; } ?> [/code] incorperate the random name and how to rename the file just uploaded? thanks
-
alright guys, this is finally what iput down and it works. thanks guys [code] if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo htmlentities('<a href="http://www.hostmapics.com/"><img src="http://hostmapics.com/'); echo $target_path; echo htmlentities('"></a>'); } else{ echo "There was an error uploading the file, please try again!"; }[/code]
-
ok haha thanks
-
well i want it to echo so it says the actual code for the link, not just the unerlined link itself
-
in PHP how do i echo something so it says the code for a link? i tried but it says unexpected '<' in line 89... :(