This is a part of a code that i use to upload a video and a picture,but i want to modify the img part to upload the file in a diferent folder and i don't want it to create an unique folder for each picture.
My folder tree is like this:
publichtml>anim e>media>img
This file is inside the media folder and it works perfectly, but i need to modify the script so it can upload picture to this address publichtml>anim e>img , the only thing that i was able to do taking the "media/" part of the code was to create another folder inside anime/img but it didn't upload the picture and it also created a unique folder on its default location (anime/media/img), so im kinda stucked in here.
So i repeat just in order to make it clear, i want to take out the unique id folder creation (i removed the mkdir but i just got an error),and modify it to upload on publichtml>anim e>img but the php file should remain at its location publichtml>anim e>media.
This script was done by my partner but he has been out of reach, and im not good with php, so please help me out, i will appreciate that.
Code:
<tr>
<td>Selecciona la imagen que representara el video :<div class="upload_sub">Esta sera la imagen que visualizaran los usuarios, debe ser un screenshot del video a subir.</div></td>
<td>
<input name="img_uploaded" type="file" /> </td>
</tr>
Code:
//This function separates the extension from the rest of the file name and returns it
function findexts ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
//This applies the function to our file
$ext = findexts ($_FILES['uploaded']['name']) ;
if(isset($_FILES['img_uploaded'])){
$img_ext=findexts($_FILES['img_uploaded']['name']);
if($img_ext=='png'|| $img_ext=='jpeg' || $img_ext=='jpg' || $img_ext=='gif'){
$path2 = dirname( __FILE__ );
$slash2 = '/';
define( 'BASE_DIR2', $path2 . $slash2 );
$img_unqi_dir=uniqid('vid_img');
$dirPath2 = BASE_DIR2 . "img/".$img_unqi_dir;
@mkdir( $dirPath2, '0755' );
$img_name=uniqid($upload_time);
$img_db="http://www.mydomain.com/anime/media/img/".$img_unqi_dir."/".$img_name.".".$img_ext;
$img_id=$dirPath2."/".$img_name.".".$img_ext;
}
else{
echo '<script type="text/javascript">alert(\'Lo sentimos solo puede subir imagenes en formato gif,png,jpeg,jpg\')</script>';
$ok=0;
}
}
else{
$img_db='http://www.mydomain.com/include/anime/vid_default.jpg';
}
if($ext=='flv'||$ext=='f4v'||$ext=='mp4'){
//Crea el id unico
$ran = uniqid (rand (),true);
//This takes the random number (or timestamp) you generated and adds a . on the end, so it is ready of the file extension to be appended.
$ran2 = $ran.".";
publichtml>anim e>media>img
This file is inside the media folder and it works perfectly, but i need to modify the script so it can upload picture to this address publichtml>anim e>img , the only thing that i was able to do taking the "media/" part of the code was to create another folder inside anime/img but it didn't upload the picture and it also created a unique folder on its default location (anime/media/img), so im kinda stucked in here.
So i repeat just in order to make it clear, i want to take out the unique id folder creation (i removed the mkdir but i just got an error),and modify it to upload on publichtml>anim e>img but the php file should remain at its location publichtml>anim e>media.
This script was done by my partner but he has been out of reach, and im not good with php, so please help me out, i will appreciate that.
Comment