How do I combine file rename and upload php programs? -
i new programming, , need php.
i can use these 2 php program upload files.(individually work well) can't figure out how combine them one, 1 new program can validate, rename, , post 2 pictures.
i program included retrieve username , email address logon session of customer , verify data the form.
i grately appreciate help.thanks
these php working with
//this php validates , posts file folder "file_upload" <?php $allowedexts = array("gif", "jpeg", "jpg", "png"); $temp = explode(".", $_files["file"]["name"]); $extension = end($temp); if ((($_files["file"]["type"] == "image/gif") || ($_files["file"]["type"] == "image/jpeg") || ($_files["file"]["type"] == "image/jpg") || ($_files["file"]["type"] == "image/pjpeg") || ($_files["file"]["type"] == "image/x-png") || ($_files["file"]["type"] == "image/png")) && ($_files["file"]["size"] < 100000) && in_array($extension, $allowedexts)) { if ($_files["file"]["error"] > 0) { echo "return code: " . $_files["file"]["error"] . "<br>"; } else { //echo "upload: " . $_files["file"]["name"] . "<br>"; //echo "type: " . $_files["file"]["type"] . "<br>"; echo "size: " . ($_files["file"]["size"] / 1024) . " kb<br>"; //echo "temp file: " . $_files["file"]["tmp_name"] . "<br>"; if (file_exists("upload/" . $_files["file"]["name"])) { echo $_files["file"]["name"] . " exists. "; } else { move_uploaded_file($_files["file"]["tmp_name"], "file_upload/" . $_files["file"]["name"]); //echo "stored in: " . "file_upload/" . $_files["file"]["name"]; } } } else { echo "invalid file"; } ?> //these php works fine rename , post files separate folders //when same user name manually entered in form <?php $destdir = 'rename_fotos/'; //can directory on server, $renamedfilename = $_post['numbera']."-foto1"; //keep same file extension if uploaded file has $renamedfilename .= ($pos = strrpos($_files['file']['name'], '.')) === false ? '' : substr($_files['file']['name'], $pos); move_uploaded_file($_files["file"]["tmp_name"], $destdir . directory_separator . $renamedfilename); echo "foto file uploaded <b>(code need upgrade!)</b>"; ?> <?php $destdir = 'rename_fotos2/'; //can directory on server,` $renamedfilename = $_post['number']."-foto2"; //keep same file extension if uploaded file has $renamedfilename .= ($pos = strrpos($_files['file2']['name'], '.')) === false ? '' : substr($_files['file2']['name'], $pos); move_uploaded_file($_files["file2"]["tmp_name"], $destdir . directory_separator . $renamedfilename); echo "foto file uploaded <b>(code need upgrade!)</b>"; ?>
try start minus logic. maybe looking @ can work better. wan't do? it's so....
if (is_valid_upload_image($_files['file']) && is_valid_number($_post['number'])) { $moved_file = move_to_definetely_local($_files['file']); rename_file_with_postname($moved_file, $post['number']); }
all functions
/methods
must created now, logic in head, can work on each more efficiently.
Comments
Post a Comment